effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.HyperStack.ST.Stack | val repeat_range:
#a:Type0 ->
l: UInt32.t ->
min:UInt32.t ->
max:UInt32.t{UInt32.v min <= UInt32.v max} ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> i:nat{i < UInt32.v max} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
fc:(b:buffer a{length b = UInt32.v l} -> i:UInt32.t{UInt32.v i < UInt32.v max} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0 (UInt32.v i))))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_range_spec (UInt32.v min) (UInt32.v max) f s) )) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let repeat_range #a l min max f b fc =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v max /\ UInt32.v min <= i
/\ as_seq h1 b == repeat_range_spec (UInt32.v min) i f (as_seq h0 b)
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v max ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
fc b i;
lemma_repeat_range_spec (UInt32.v min) (UInt32.v i + 1) f (as_seq h0 b)
in
lemma_repeat_range_0 (UInt32.v min) f (as_seq h0 b);
for min max inv f' | val repeat_range:
#a:Type0 ->
l: UInt32.t ->
min:UInt32.t ->
max:UInt32.t{UInt32.v min <= UInt32.v max} ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> i:nat{i < UInt32.v max} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
fc:(b:buffer a{length b = UInt32.v l} -> i:UInt32.t{UInt32.v i < UInt32.v max} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0 (UInt32.v i))))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_range_spec (UInt32.v min) (UInt32.v max) f s) ))
let repeat_range #a l min max f b fc = | true | null | false | let h0 = HST.get () in
let inv (h1: HS.mem) (i: nat) : Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v max /\ UInt32.v min <= i /\
as_seq h1 b == repeat_range_spec (UInt32.v min) i f (as_seq h0 b)
in
let f' (i: UInt32.t{let open UInt32 in 0 <= v i /\ v i < v max})
: Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> let open UInt32 in inv h_2 (v i + 1))) =
fc b i;
lemma_repeat_range_spec (UInt32.v min) (UInt32.v i + 1) f (as_seq h0 b)
in
lemma_repeat_range_0 (UInt32.v min) f (as_seq h0 b);
for min max inv f' | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"FStar.Seq.Base.seq",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.Seq.Base.length",
"Prims.nat",
"Prims.op_LessThan",
"FStar.Buffer.buffer",
"FStar.Buffer.length",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.Buffer.live",
"Prims.l_and",
"FStar.Buffer.modifies_1",
"Prims.eq2",
"FStar.Buffer.as_seq",
"C.Compat.Loops.for",
"Spec.Loops.lemma_repeat_range_0",
"Prims.op_Addition",
"Spec.Loops.lemma_repeat_range_spec",
"Spec.Loops.repeat_range_spec",
"FStar.HyperStack.ST.get"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end
(* To be extracted as:
int i = <start>;
bool b = false;
for (; (!b) && (i != <end>); --i) {
b = <f> i;
}
// i and b must be in scope after the loop
*)
val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_reverse_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start -^ 1ul) in
if f start
then (start', true)
else interruptible_reverse_for start' finish inv f
(* Non-primitive combinators that can be expressed in terms of the above ******)
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in[i]);
*)
inline_for_extraction
val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) ))
inline_for_extraction
let map #a #b output input l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 input /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 input j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = input.(i) in
output.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map f (as_seq h0 input))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let map2 #a #b #c output in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 in1 /\ live h1 in2 /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
output.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* b[i] = <f>(b[i]);
*)
inline_for_extraction
val in_place_map:
#a:Type0 ->
b: buffer a ->
l: UInt32.t{ UInt32.v l = Buffer.length b } ->
f:(a -> Tot a) ->
Stack unit
(requires (fun h -> live h b))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_2 b /\ live h_1 b
/\ (let s1 = as_seq h_1 b in
let s2 = as_seq h_2 b in
s2 == seq_map f s1) ))
inline_for_extraction
let in_place_map #a b l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 b j == get h0 b j)
/\ (forall (j:nat). j < i ==> get h1 b j == f (get h0 b j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = b.(i) in
b.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 b) (seq_map f (as_seq h0 b))
(** Extracts as (destination buffer comes first):
* for (int i = 0; i < <l>; ++i)
* in1[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val in_place_map2:
#a:Type0 -> #b:Type0 ->
in1: buffer a ->
in2: buffer b{disjoint in1 in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length in1 /\ UInt32.v l = Buffer.length in2} ->
f:(a -> b -> Tot a) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2))
(ensures (fun h_1 r h_2 -> modifies_1 in1 h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 in1 in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let in_place_map2 #a #b in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 in1 /\ live h1 in2 /\ modifies_1 in1 h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 in1 j == get h0 in1 j)
/\ (forall (j:nat). j < i ==> get h1 in1 j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
in1.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 in1) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
#reset-options "--initial_fuel 2 --max_fuel 2 --z3rlimit 20"
(* Repeating the same operation a number of times over a buffer ***************)
#reset-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** To be extracted as:
* for (int i = 0; i < n; ++i)
* f(b[i]);
*)
inline_for_extraction
val repeat:
#a:Type0 ->
l: UInt32.t ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
max:UInt32.t ->
fc:(b:buffer a{length b = UInt32.v l} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0)))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_spec (UInt32.v max) f s) ))
inline_for_extraction
let repeat #a l f b max fc =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v max
/\ as_seq h1 b == repeat_spec i f (as_seq h0 b)
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v max ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
fc b;
lemma_repeat (UInt32.v i + 1) f (as_seq h0 b)
in
lemma_repeat_0 0 f (as_seq h0 b);
for 0ul max inv f'
(** To be extracted as:
* for (int i = min; i < max; ++i)
* f(b[i], i);
*)
inline_for_extraction
val repeat_range:
#a:Type0 ->
l: UInt32.t ->
min:UInt32.t ->
max:UInt32.t{UInt32.v min <= UInt32.v max} ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> i:nat{i < UInt32.v max} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
fc:(b:buffer a{length b = UInt32.v l} -> i:UInt32.t{UInt32.v i < UInt32.v max} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0 (UInt32.v i))))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_range_spec (UInt32.v min) (UInt32.v max) f s) )) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val repeat_range:
#a:Type0 ->
l: UInt32.t ->
min:UInt32.t ->
max:UInt32.t{UInt32.v min <= UInt32.v max} ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> i:nat{i < UInt32.v max} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
fc:(b:buffer a{length b = UInt32.v l} -> i:UInt32.t{UInt32.v i < UInt32.v max} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0 (UInt32.v i))))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_range_spec (UInt32.v min) (UInt32.v max) f s) )) | [] | C.Compat.Loops.repeat_range | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
l: FStar.UInt32.t ->
min: FStar.UInt32.t ->
max: FStar.UInt32.t{FStar.UInt32.v min <= FStar.UInt32.v max} ->
f:
(
s: FStar.Seq.Base.seq a {FStar.Seq.Base.length s = FStar.UInt32.v l} ->
i: Prims.nat{i < FStar.UInt32.v max}
-> s': FStar.Seq.Base.seq a {FStar.Seq.Base.length s' = FStar.Seq.Base.length s}) ->
b: FStar.Buffer.buffer a {FStar.Buffer.length b = FStar.UInt32.v l} ->
fc:
(
b: FStar.Buffer.buffer a {FStar.Buffer.length b = FStar.UInt32.v l} ->
i: FStar.UInt32.t{FStar.UInt32.v i < FStar.UInt32.v max}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 20,
"end_line": 444,
"start_col": 38,
"start_line": 430
} |
FStar.HyperStack.ST.Stack | val in_place_map2:
#a:Type0 -> #b:Type0 ->
in1: buffer a ->
in2: buffer b{disjoint in1 in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length in1 /\ UInt32.v l = Buffer.length in2} ->
f:(a -> b -> Tot a) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2))
(ensures (fun h_1 r h_2 -> modifies_1 in1 h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 in1 in
s == seq_map2 f s1 s2) )) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let in_place_map2 #a #b in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 in1 /\ live h1 in2 /\ modifies_1 in1 h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 in1 j == get h0 in1 j)
/\ (forall (j:nat). j < i ==> get h1 in1 j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
in1.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 in1) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2)) | val in_place_map2:
#a:Type0 -> #b:Type0 ->
in1: buffer a ->
in2: buffer b{disjoint in1 in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length in1 /\ UInt32.v l = Buffer.length in2} ->
f:(a -> b -> Tot a) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2))
(ensures (fun h_1 r h_2 -> modifies_1 in1 h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 in1 in
s == seq_map2 f s1 s2) ))
let in_place_map2 #a #b in1 in2 l f = | true | null | false | let h0 = HST.get () in
let inv (h1: HS.mem) (i: nat) : Type0 =
live h1 in1 /\ live h1 in2 /\ modifies_1 in1 h0 h1 /\ i <= UInt32.v l /\
(forall (j: nat). (j >= i /\ j < UInt32.v l) ==> get h1 in1 j == get h0 in1 j) /\
(forall (j: nat). j < i ==> get h1 in1 j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i: UInt32.t{let open UInt32 in 0 <= v i /\ v i < v l})
: Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> let open UInt32 in inv h_2 (v i + 1))) =
let xi = in1.(i) in
let yi = in2.(i) in
in1.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get () in
Seq.lemma_eq_intro (as_seq h1 in1) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2)) | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.Buffer.buffer",
"FStar.Buffer.disjoint",
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"FStar.Buffer.length",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Buffer.as_seq",
"Spec.Loops.seq_map2",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"C.Compat.Loops.for",
"FStar.UInt32.__uint_to_t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Buffer.op_Array_Assignment",
"FStar.Buffer.op_Array_Access",
"Prims.nat",
"FStar.Buffer.live",
"FStar.Buffer.modifies_1",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"FStar.Buffer.get"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end
(* To be extracted as:
int i = <start>;
bool b = false;
for (; (!b) && (i != <end>); --i) {
b = <f> i;
}
// i and b must be in scope after the loop
*)
val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_reverse_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start -^ 1ul) in
if f start
then (start', true)
else interruptible_reverse_for start' finish inv f
(* Non-primitive combinators that can be expressed in terms of the above ******)
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in[i]);
*)
inline_for_extraction
val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) ))
inline_for_extraction
let map #a #b output input l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 input /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 input j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = input.(i) in
output.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map f (as_seq h0 input))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let map2 #a #b #c output in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 in1 /\ live h1 in2 /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
output.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* b[i] = <f>(b[i]);
*)
inline_for_extraction
val in_place_map:
#a:Type0 ->
b: buffer a ->
l: UInt32.t{ UInt32.v l = Buffer.length b } ->
f:(a -> Tot a) ->
Stack unit
(requires (fun h -> live h b))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_2 b /\ live h_1 b
/\ (let s1 = as_seq h_1 b in
let s2 = as_seq h_2 b in
s2 == seq_map f s1) ))
inline_for_extraction
let in_place_map #a b l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 b j == get h0 b j)
/\ (forall (j:nat). j < i ==> get h1 b j == f (get h0 b j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = b.(i) in
b.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 b) (seq_map f (as_seq h0 b))
(** Extracts as (destination buffer comes first):
* for (int i = 0; i < <l>; ++i)
* in1[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val in_place_map2:
#a:Type0 -> #b:Type0 ->
in1: buffer a ->
in2: buffer b{disjoint in1 in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length in1 /\ UInt32.v l = Buffer.length in2} ->
f:(a -> b -> Tot a) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2))
(ensures (fun h_1 r h_2 -> modifies_1 in1 h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 in1 in
s == seq_map2 f s1 s2) )) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val in_place_map2:
#a:Type0 -> #b:Type0 ->
in1: buffer a ->
in2: buffer b{disjoint in1 in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length in1 /\ UInt32.v l = Buffer.length in2} ->
f:(a -> b -> Tot a) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2))
(ensures (fun h_1 r h_2 -> modifies_1 in1 h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 in1 in
s == seq_map2 f s1 s2) )) | [] | C.Compat.Loops.in_place_map2 | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
in1: FStar.Buffer.buffer a ->
in2: FStar.Buffer.buffer b {FStar.Buffer.disjoint in1 in2} ->
l:
FStar.UInt32.t
{FStar.UInt32.v l = FStar.Buffer.length in1 /\ FStar.UInt32.v l = FStar.Buffer.length in2} ->
f: (_: a -> _: b -> a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 81,
"end_line": 354,
"start_col": 37,
"start_line": 337
} |
FStar.HyperStack.ST.Stack | val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) )) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map #a #b output input l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 input /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 input j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = input.(i) in
output.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map f (as_seq h0 input)) | val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) ))
let map #a #b output input l f = | true | null | false | let h0 = HST.get () in
let inv (h1: HS.mem) (i: nat) : Type0 =
live h1 output /\ live h1 input /\ modifies_1 output h0 h1 /\ i <= UInt32.v l /\
(forall (j: nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j) /\
(forall (j: nat). j < i ==> get h1 output j == f (get h0 input j))
in
let f' (i: UInt32.t{let open UInt32 in 0 <= v i /\ v i < v l})
: Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> let open UInt32 in inv h_2 (v i + 1))) =
let xi = input.(i) in
output.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get () in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map f (as_seq h0 input)) | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.Buffer.buffer",
"FStar.Buffer.disjoint",
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"FStar.Buffer.length",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Buffer.as_seq",
"Spec.Loops.seq_map",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"C.Compat.Loops.for",
"FStar.UInt32.__uint_to_t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Buffer.op_Array_Assignment",
"FStar.Buffer.op_Array_Access",
"Prims.nat",
"FStar.Buffer.live",
"FStar.Buffer.modifies_1",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"FStar.Buffer.get"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end
(* To be extracted as:
int i = <start>;
bool b = false;
for (; (!b) && (i != <end>); --i) {
b = <f> i;
}
// i and b must be in scope after the loop
*)
val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_reverse_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start -^ 1ul) in
if f start
then (start', true)
else interruptible_reverse_for start' finish inv f
(* Non-primitive combinators that can be expressed in terms of the above ******)
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in[i]);
*)
inline_for_extraction
val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) )) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) )) | [] | C.Compat.Loops.map | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
output: FStar.Buffer.buffer b ->
input: FStar.Buffer.buffer a {FStar.Buffer.disjoint input output} ->
l:
FStar.UInt32.t
{ FStar.UInt32.v l = FStar.Buffer.length output /\
FStar.UInt32.v l = FStar.Buffer.length input } ->
f: (_: a -> b)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 69,
"end_line": 237,
"start_col": 32,
"start_line": 221
} |
FStar.HyperStack.ST.Stack | val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) )) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map2 #a #b #c output in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 in1 /\ live h1 in2 /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
output.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2)) | val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) ))
let map2 #a #b #c output in1 in2 l f = | true | null | false | let h0 = HST.get () in
let inv (h1: HS.mem) (i: nat) : Type0 =
live h1 output /\ live h1 in1 /\ live h1 in2 /\ modifies_1 output h0 h1 /\ i <= UInt32.v l /\
(forall (j: nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j) /\
(forall (j: nat). j < i ==> get h1 output j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i: UInt32.t{let open UInt32 in 0 <= v i /\ v i < v l})
: Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> let open UInt32 in inv h_2 (v i + 1))) =
let xi = in1.(i) in
let yi = in2.(i) in
output.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get () in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2)) | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.Buffer.buffer",
"FStar.Buffer.disjoint",
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"FStar.Buffer.length",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Buffer.as_seq",
"Spec.Loops.seq_map2",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"C.Compat.Loops.for",
"FStar.UInt32.__uint_to_t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Buffer.op_Array_Assignment",
"FStar.Buffer.op_Array_Access",
"Prims.nat",
"FStar.Buffer.live",
"FStar.Buffer.modifies_1",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"FStar.Buffer.get"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end
(* To be extracted as:
int i = <start>;
bool b = false;
for (; (!b) && (i != <end>); --i) {
b = <f> i;
}
// i and b must be in scope after the loop
*)
val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_reverse_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start -^ 1ul) in
if f start
then (start', true)
else interruptible_reverse_for start' finish inv f
(* Non-primitive combinators that can be expressed in terms of the above ******)
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in[i]);
*)
inline_for_extraction
val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) ))
inline_for_extraction
let map #a #b output input l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 input /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 input j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = input.(i) in
output.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map f (as_seq h0 input))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) )) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) )) | [] | C.Compat.Loops.map2 | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
output: FStar.Buffer.buffer c ->
in1: FStar.Buffer.buffer a {FStar.Buffer.disjoint output in1} ->
in2: FStar.Buffer.buffer b {FStar.Buffer.disjoint output in2} ->
l:
FStar.UInt32.t
{ FStar.UInt32.v l = FStar.Buffer.length output /\
FStar.UInt32.v l = FStar.Buffer.length in1 /\ FStar.UInt32.v l = FStar.Buffer.length in2 } ->
f: (_: a -> _: b -> c)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 84,
"end_line": 278,
"start_col": 38,
"start_line": 261
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.TypesNative_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow2_norm = Vale.Def.Words_s.pow2_norm | let pow2_norm = | false | null | false | Vale.Def.Words_s.pow2_norm | {
"checked_file": "Vale.Arch.TypesNative.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.TypesNative_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.TypesNative.fsti"
} | [
"total"
] | [
"Vale.Def.Words_s.pow2_norm"
] | [] | module Vale.Arch.TypesNative
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.TypesNative_s
open FStar.Seq
unfold let nth (#n:pos) (a:UInt.uint_t n) (i:nat{i < n}) : bool = index (UInt.to_vec #n a) i | false | true | Vale.Arch.TypesNative.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow2_norm : n: Prims.nat -> Prims.pos | [] | Vale.Arch.TypesNative.pow2_norm | {
"file_name": "vale/code/arch/Vale.Arch.TypesNative.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Prims.nat -> Prims.pos | {
"end_col": 49,
"end_line": 10,
"start_col": 23,
"start_line": 10
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.TypesNative_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let natN = Vale.Def.Words_s.natN | let natN = | false | null | false | Vale.Def.Words_s.natN | {
"checked_file": "Vale.Arch.TypesNative.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.TypesNative_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.TypesNative.fsti"
} | [
"total"
] | [
"Vale.Def.Words_s.natN"
] | [] | module Vale.Arch.TypesNative
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.TypesNative_s
open FStar.Seq | false | true | Vale.Arch.TypesNative.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val natN : n: Prims.nat -> Type0 | [] | Vale.Arch.TypesNative.natN | {
"file_name": "vale/code/arch/Vale.Arch.TypesNative.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Prims.nat -> Type0 | {
"end_col": 39,
"end_line": 9,
"start_col": 18,
"start_line": 9
} |
|
Prims.Tot | val not (b: bool) : bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.TypesNative_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let not (b:bool) : bool = if b then false else true | val not (b: bool) : bool
let not (b: bool) : bool = | false | null | false | if b then false else true | {
"checked_file": "Vale.Arch.TypesNative.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.TypesNative_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.TypesNative.fsti"
} | [
"total"
] | [
"Prims.bool"
] | [] | module Vale.Arch.TypesNative
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.TypesNative_s
open FStar.Seq
unfold let nth (#n:pos) (a:UInt.uint_t n) (i:nat{i < n}) : bool = index (UInt.to_vec #n a) i
unfold let natN = Vale.Def.Words_s.natN
unfold let pow2_norm = Vale.Def.Words_s.pow2_norm
val lemma_equal_nth (n:pos) (x y:natN (pow2 n)) : Lemma
(requires (forall (i:nat).{:pattern (nth #n x i) \/ (nth #n y i)} i < n ==> nth #n x i == nth #n y i))
(ensures x == y)
val lemma_zero_nth (n:nat) : Lemma
(forall (i:nat{i < n}).{:pattern (nth #n 0 i)} not (nth #n 0 i))
val lemma_quad32_vec_equal (a b:quad32) : Lemma
(requires (
let Mkfour a0 a1 a2 a3 = a in
let Mkfour b0 b1 b2 b3 = b in
equal (UInt.to_vec #32 a0) (UInt.to_vec #32 b0) /\
equal (UInt.to_vec #32 a1) (UInt.to_vec #32 b1) /\
equal (UInt.to_vec #32 a2) (UInt.to_vec #32 b2) /\
equal (UInt.to_vec #32 a3) (UInt.to_vec #32 b3)
))
(ensures a == b)
val lemma_iand_nth_i (n:pos) (x y:natN (pow2 n)) (i:nat{i < n}) : Lemma
(nth #n (iand x y) i == (nth #n x i && nth #n y i))
val lemma_ixor_nth_i (n:pos) (x y:natN (pow2 n)) (i:nat{i < n}) : Lemma
(nth #n (ixor x y) i == (nth #n x i <> nth #n y i))
val lemma_ior_nth_i (n:pos) (x y:natN (pow2 n)) (i:nat{i < n}) : Lemma
(nth #n (ior x y) i == (nth #n x i || nth #n y i))
val lemma_inot_nth_i (n:pos) (x:natN (pow2 n)) (i:nat{i < n}) : Lemma
(nth #n (inot x) i == not (nth #n x i))
val lemma_ishl_nth_i (n:pos) (x:natN (pow2 n)) (y:nat) (i:nat{i < n}) : Lemma
(nth #n (ishl x y) i == (i + y < n && nth #n x (i + y)))
val lemma_ishr_nth_i (n:pos) (x:natN (pow2 n)) (y:nat) (i:nat{i < n}) : Lemma
(nth #n (ishr x y) i == (i - y >= 0 && nth #n x (i - y)))
val lemma_iand_nth (n:pos) (x y:natN (pow2 n)) : Lemma
(forall (m:_{m==pow2_norm n}) (i:nat{i < n}).{:pattern (nth #n (iand #m x y) i)}
nth #n (iand #m x y) i == (nth #n x i && nth #n y i))
val lemma_ixor_nth (n:pos) (x y:natN (pow2 n)) : Lemma
(forall (m:_{m==pow2_norm n}) (i:nat{i < n}).{:pattern (nth #n (ixor #m x y) i)}
nth #n (ixor #m x y) i == (nth #n x i <> nth #n y i))
val lemma_ior_nth (n:pos) (x y:natN (pow2 n)) : Lemma
(forall (m:_{m==pow2_norm n}) (i:nat{i < n}).{:pattern (nth #n (ior #m x y) i)}
nth #n (ior #m x y) i == (nth #n x i || nth #n y i))
val lemma_inot_nth (n:pos) (x:natN (pow2 n)) : Lemma
(forall (m:_{m==pow2_norm n}) (i:nat{i < n}).{:pattern (nth #n (inot #m x) i)}
nth #n (inot #m x) i == not (nth #n x i))
val lemma_ishl_nth (n:pos) (x:natN (pow2 n)) (y:nat) : Lemma
(forall (m:_{m==pow2_norm n}) (i:nat{i < n}).{:pattern (nth #n (ishl #m x y) i)}
nth #n (ishl #m x y) i == (i + y < n && nth #n x (i + y)))
val lemma_ishr_nth (n:pos) (x:natN (pow2 n)) (y:nat) : Lemma
(forall (m:_{m==pow2_norm n}) (i:nat{i < n}).{:pattern (nth #n (ishr #m x y) i)}
nth #n (ishr #m x y) i == (i - y >= 0 && nth #n x (i - y)))
val lemma_iand_nth_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x y:natN (pow2 n)).{:pattern (iand #m x y)}
(forall (i:nat{i < n}).{:pattern (nth #n (iand #m x y) i)}
nth #n (iand #m x y) i == (nth #n x i && nth #n y i)))
val lemma_ixor_nth_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x y:natN (pow2 n)).{:pattern (ixor #m x y)}
(forall (i:nat{i < n}).{:pattern (nth #n (ixor #m x y) i)}
nth #n (ixor #m x y) i == (nth #n x i <> nth #n y i)))
val lemma_ior_nth_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x y:natN (pow2 n)).{:pattern (ior #m x y)}
(forall (i:nat{i < n}).{:pattern (nth #n (ior #m x y) i)}
nth #n (ior #m x y) i == (nth #n x i || nth #n y i)))
val lemma_inot_nth_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x:natN (pow2 n)).{:pattern (inot #m x)}
(forall (i:nat{i < n}).{:pattern (nth #n (inot #m x) i)}
nth #n (inot #m x) i == not (nth #n x i)))
val lemma_ishl_nth_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x:natN (pow2 n)) (y:nat).{:pattern (ishl #m x y)}
(forall (i:nat{i < n}).{:pattern (nth #n (ishl #m x y) i)}
nth #n (ishl #m x y) i == (i + y < n && nth #n x (i + y))))
val lemma_ishr_nth_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x:natN (pow2 n)) (y:nat).{:pattern (ishr #m x y)}
(forall (i:nat{i < n}).{:pattern (nth #n (ishr #m x y) i)}
nth #n (ishr #m x y) i == (i - y >= 0 && nth #n x (i - y))))
val reveal_iand_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x y:natN (pow2 n)).{:pattern (iand #m x y)}
iand #m x y == UInt.logand #n x y)
val reveal_ixor_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x y:natN (pow2 n)).{:pattern (ixor #m x y)}
ixor #m x y == UInt.logxor #n x y)
val reveal_ior_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x y:natN (pow2 n)).{:pattern (ior #m x y)}
ior #m x y == UInt.logor #n x y)
val reveal_inot_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x:natN (pow2 n)).{:pattern (inot #m x)}
inot #m x == UInt.lognot #n x)
val reveal_ishl_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x:natN (pow2 n)) (y:nat).{:pattern (ishl #m x y)}
ishl #m x y == UInt.shift_left #n x y)
val reveal_ishr_all (n:pos) : Lemma
(forall (m:_{m==pow2_norm n}) (x:natN (pow2 n)) (y:nat).{:pattern (ishr #m x y)}
ishr #m x y == UInt.shift_right #n x y)
val lemma_nat32_xor_commutes (x y:nat32) : Lemma
(nat32_xor x y = nat32_xor y x)
val lemma_nat32_xor_commutes_forall (_:unit) : Lemma
(forall (x y:nat32) . nat32_xor x y = nat32_xor y x)
val lemma_quad32_xor_commutes (x y:quad32) :Lemma
(quad32_xor x y = quad32_xor y x)
val lemma_quad32_xor_commutes_forall (_:unit) : Lemma
(forall (x y:quad32) . {:pattern (quad32_xor x y)} quad32_xor x y = quad32_xor y x)
val lemma_quad32_xor_associates (x y z:quad32) : Lemma
(quad32_xor (quad32_xor x y) z == (quad32_xor x (quad32_xor y z)))
val lemma_iand_pow2 (n:pos) (x:natN (pow2 n)) (i:nat{i < n}) : Lemma
(pow2 i < pow2 n /\ (iand x (pow2 i) == 0 \/ iand x (pow2 i) == pow2 i))
val lemma_ishr_pow2_diff (n:pos) (i:nat{i < n}) (j:nat{i <= j /\ j < n}) : Lemma
(pow2 j < pow2 n /\ ishr #(pow2 n) (pow2 j) (j - i) == pow2 i) | false | true | Vale.Arch.TypesNative.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val not (b: bool) : bool | [] | Vale.Arch.TypesNative.not | {
"file_name": "vale/code/arch/Vale.Arch.TypesNative.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Prims.bool -> Prims.bool | {
"end_col": 51,
"end_line": 147,
"start_col": 26,
"start_line": 147
} |
Prims.Tot | val nth (#n: pos) (a: UInt.uint_t n) (i: nat{i < n}) : bool | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.TypesNative_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nth (#n:pos) (a:UInt.uint_t n) (i:nat{i < n}) : bool = index (UInt.to_vec #n a) i | val nth (#n: pos) (a: UInt.uint_t n) (i: nat{i < n}) : bool
let nth (#n: pos) (a: UInt.uint_t n) (i: nat{i < n}) : bool = | false | null | false | index (UInt.to_vec #n a) i | {
"checked_file": "Vale.Arch.TypesNative.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.TypesNative_s.fst.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Arch.TypesNative.fsti"
} | [
"total"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Prims.bool",
"FStar.UInt.to_vec"
] | [] | module Vale.Arch.TypesNative
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.TypesNative_s
open FStar.Seq | false | false | Vale.Arch.TypesNative.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nth (#n: pos) (a: UInt.uint_t n) (i: nat{i < n}) : bool | [] | Vale.Arch.TypesNative.nth | {
"file_name": "vale/code/arch/Vale.Arch.TypesNative.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt.uint_t n -> i: Prims.nat{i < n} -> Prims.bool | {
"end_col": 92,
"end_line": 8,
"start_col": 66,
"start_line": 8
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_counter = 0xfcfdfeff | let test_counter = | false | null | false | 0xfcfdfeff | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l | false | true | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_counter : Prims.int | [] | Spec.AES.Test.test_counter | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.int | {
"end_col": 29,
"end_line": 29,
"start_col": 19,
"start_line": 29
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_counter1 = 1 | let test_counter1 = | false | null | false | 1 | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | true | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_counter1 : Prims.int | [] | Spec.AES.Test.test_counter1 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.int | {
"end_col": 21,
"end_line": 62,
"start_col": 20,
"start_line": 62
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_counter2 = 1 | let test_counter2 = | false | null | false | 1 | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l | false | true | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_counter2 : Prims.int | [] | Spec.AES.Test.test_counter2 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.int | {
"end_col": 21,
"end_line": 95,
"start_col": 20,
"start_line": 95
} |
|
Prims.Tot | val test_nonce:lbytes 12 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l | val test_nonce:lbytes 12
let test_nonce:lbytes 12 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy; 0xfauy; 0xfbuy]
in
assert_norm (List.Tot.length l == 12);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_nonce:lbytes 12 | [] | Spec.AES.Test.test_nonce | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 12 | {
"end_col": 11,
"end_line": 27,
"start_col": 29,
"start_line": 22
} |
Prims.Tot | val test2_key_block:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test2_key_block:lbytes 16
let test2_key_block:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test2_key_block:lbytes 16 | [] | Spec.AES.Test.test2_key_block | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 146,
"start_col": 33,
"start_line": 141
} |
FStar.All.ML | val print_sbox: Prims.unit -> FStar.All.ML unit | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n" | val print_sbox: Prims.unit -> FStar.All.ML unit
let print_sbox () : FStar.All.ML unit = | true | null | false | let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[ i ] <- u8 i) seq in
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a ->
IO.print_string (UInt8.to_string (u8_to_UInt8 a));
IO.print_string " ; ")
(to_list #uint8 seqsbox);
IO.print_string "\n" | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"ml"
] | [
"Prims.unit",
"FStar.IO.print_string",
"FStar.List.iter",
"Lib.IntTypes.uint8",
"FStar.UInt8.to_string",
"Lib.RawIntTypes.u8_to_UInt8",
"Lib.Sequence.to_list",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.Sequence.index",
"Spec.AES.sub_byte",
"Spec.AES.elem",
"Lib.Sequence.map",
"Lib.LoopCombinators.repeati",
"Lib.Sequence.op_String_Assignment",
"Lib.IntTypes.u8",
"Prims.l_and",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Lib.Sequence.create"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val print_sbox: Prims.unit -> FStar.All.ML unit | [] | Spec.AES.Test.print_sbox | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> FStar.All.ML Prims.unit | {
"end_col": 22,
"end_line": 318,
"start_col": 39,
"start_line": 306
} |
Prims.Tot | val test_ciphertext1:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test_ciphertext1:lbytes 16
let test_ciphertext1:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy; 0x2Duy; 0x61uy; 0x75uy; 0xA3uy;
0x26uy; 0x13uy; 0x11uy; 0xB8uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_ciphertext1:lbytes 16 | [] | Spec.AES.Test.test_ciphertext1 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 77,
"start_col": 34,
"start_line": 72
} |
Prims.Tot | val test_nonce1:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test_nonce1:lbytes 16
let test_nonce1:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_nonce1:lbytes 16 | [] | Spec.AES.Test.test_nonce1 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 60,
"start_col": 29,
"start_line": 55
} |
Prims.Tot | val test_vectors:list vec | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_vectors : list vec = [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
] | val test_vectors:list vec
let test_vectors:list vec = | false | null | false | [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
] | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Prims.Cons",
"Spec.AES.Test.vec",
"Spec.AES.Test.Vec",
"Spec.AES.AES128",
"Spec.AES.Test.test_key",
"Spec.AES.Test.test_nonce",
"Spec.AES.Test.test_counter",
"Spec.AES.Test.test_plaintext",
"Spec.AES.Test.test_ciphertext",
"Spec.AES.Test.test_key1",
"Spec.AES.Test.test_nonce1",
"Spec.AES.Test.test_counter1",
"Spec.AES.Test.test_plaintext1",
"Spec.AES.Test.test_ciphertext1",
"Spec.AES.Test.test_key2",
"Spec.AES.Test.test_nonce2",
"Spec.AES.Test.test_counter2",
"Spec.AES.Test.test_plaintext2",
"Spec.AES.Test.test_ciphertext2",
"Spec.AES.Test.Vec_block",
"Spec.AES.Test.test1_key_block",
"Spec.AES.Test.test1_plaintext_block",
"Spec.AES.Test.test1_ciphertext_block",
"Spec.AES.Test.test2_key_block",
"Spec.AES.Test.test2_plaintext_block",
"Spec.AES.Test.test2_ciphertext_block",
"Spec.AES.Test.test3_key_block",
"Spec.AES.Test.test3_ciphertext_block",
"Spec.AES.AES256",
"Spec.AES.Test.test2_input_key",
"Spec.AES.Test.test2_input_plaintext",
"Spec.AES.Test.test2_output_ciphertext",
"Spec.AES.Test.test3_input_key",
"Spec.AES.Test.test3_input_plaintext",
"Spec.AES.Test.test3_output_ciphertext",
"Spec.AES.Test.test4_input_key",
"Spec.AES.Test.test4_input_plaintext",
"Spec.AES.Test.test4_output_ciphertext",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n"
(*
let seqsbox_16 = map (fun s -> sbox_bp_16 s) seqi in
IO.print_string "sbox bp_i i:\n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox_16);
IO.print_string "\n";
*)
noeq type vec =
| Vec :
v:variant
-> key:aes_key v
-> nonce:bytes{length nonce <= 16}
-> c:size_nat
-> msg:bytes{length msg / 16 + c <= max_size_t}
-> expected:bytes{length msg = length expected /\ length msg <= max_size_t} -> vec
| Vec_block :
v:variant
-> key:aes_key v
-> plain:block
-> expected:block -> vec | false | true | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_vectors:list vec | [] | Spec.AES.Test.test_vectors | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.list Spec.AES.Test.vec | {
"end_col": 1,
"end_line": 353,
"start_col": 30,
"start_line": 342
} |
Prims.Tot | val test1_plaintext_block:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test1_plaintext_block:lbytes 16
let test1_plaintext_block:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test1_plaintext_block:lbytes 16 | [] | Spec.AES.Test.test1_plaintext_block | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 130,
"start_col": 39,
"start_line": 125
} |
Prims.Tot | val test_plaintext1:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test_plaintext1:lbytes 16
let test_plaintext1:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy; 0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy;
0x20uy; 0x6Duy; 0x73uy; 0x67uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1 | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_plaintext1:lbytes 16 | [] | Spec.AES.Test.test_plaintext1 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 69,
"start_col": 33,
"start_line": 64
} |
Prims.Tot | val test3_input_plaintext:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test3_input_plaintext:lbytes 16
let test3_input_plaintext:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test3_input_plaintext:lbytes 16 | [] | Spec.AES.Test.test3_input_plaintext | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 269,
"start_col": 39,
"start_line": 264
} |
Prims.Tot | val test4_input_plaintext:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test4_input_plaintext:lbytes 16
let test4_input_plaintext:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test4_input_plaintext:lbytes 16 | [] | Spec.AES.Test.test4_input_plaintext | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 295,
"start_col": 39,
"start_line": 290
} |
Prims.Tot | val test_key:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test_key:lbytes 16
let test_key:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy; 0xabuy; 0xf7uy; 0x15uy; 0x88uy;
0x09uy; 0xcfuy; 0x4fuy; 0x3cuy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_key:lbytes 16 | [] | Spec.AES.Test.test_key | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 19,
"start_col": 26,
"start_line": 14
} |
Prims.Tot | val test_key2:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test_key2:lbytes 16
let test_key2:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy; 0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy;
0x32uy; 0x53uy; 0x91uy; 0x63uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_key2:lbytes 16 | [] | Spec.AES.Test.test_key2 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 85,
"start_col": 27,
"start_line": 80
} |
Prims.Tot | val test_nonce2:lbytes 12 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l | val test_nonce2:lbytes 12
let test_nonce2:lbytes 12 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy; 0xDAuy; 0x48uy; 0xD9uy; 0x0Buy]
in
assert_norm (List.Tot.length l == 12);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_nonce2:lbytes 12 | [] | Spec.AES.Test.test_nonce2 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 12 | {
"end_col": 11,
"end_line": 93,
"start_col": 29,
"start_line": 88
} |
Prims.Tot | val test3_key_block:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test3_key_block:lbytes 16
let test3_key_block:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy; 0x6duy; 0x6auy; 0x8fuy; 0x94uy;
0x67uy; 0x30uy; 0x83uy; 0x08uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test3_key_block:lbytes 16 | [] | Spec.AES.Test.test3_key_block | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 170,
"start_col": 33,
"start_line": 165
} |
Prims.Tot | val test2_input_plaintext:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test2_input_plaintext:lbytes 16
let test2_input_plaintext:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy; 0x88uy; 0x99uy; 0xaauy; 0xbbuy;
0xccuy; 0xdduy; 0xeeuy; 0xffuy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test2_input_plaintext:lbytes 16 | [] | Spec.AES.Test.test2_input_plaintext | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 243,
"start_col": 39,
"start_line": 238
} |
Prims.Tot | val test2_plaintext_block:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test2_plaintext_block:lbytes 16
let test2_plaintext_block:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test2_plaintext_block:lbytes 16 | [] | Spec.AES.Test.test2_plaintext_block | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 154,
"start_col": 39,
"start_line": 149
} |
Prims.Tot | val test1_key_block:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test1_key_block:lbytes 16
let test1_key_block:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test1_key_block:lbytes 16 | [] | Spec.AES.Test.test1_key_block | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 122,
"start_col": 33,
"start_line": 117
} |
Prims.Tot | val test3_ciphertext_block:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test3_ciphertext_block:lbytes 16
let test3_ciphertext_block:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy; 0x0auy; 0xa6uy; 0xe5uy; 0x29uy;
0x80uy; 0xd5uy; 0x3buy; 0x78uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test3_ciphertext_block:lbytes 16 | [] | Spec.AES.Test.test3_ciphertext_block | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 178,
"start_col": 40,
"start_line": 173
} |
Prims.Tot | val test3_output_ciphertext:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test3_output_ciphertext:lbytes 16
let test3_output_ciphertext:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy; 0x77uy; 0x47uy; 0x6fuy; 0xc5uy;
0x01uy; 0x24uy; 0x2cuy; 0x5fuy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test3_output_ciphertext:lbytes 16 | [] | Spec.AES.Test.test3_output_ciphertext | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 277,
"start_col": 41,
"start_line": 272
} |
Prims.Tot | val test2_input_key:lbytes 32 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | val test2_input_key:lbytes 32
let test2_input_key:lbytes 32 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy;
0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test2_input_key:lbytes 32 | [] | Spec.AES.Test.test2_input_key | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | {
"end_col": 11,
"end_line": 235,
"start_col": 33,
"start_line": 228
} |
Prims.Tot | val test4_input_key:lbytes 32 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | val test4_input_key:lbytes 32
let test4_input_key:lbytes 32 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy; 0x9buy; 0xc4uy; 0x37uy; 0x48uy;
0x4euy; 0x3cuy; 0x5cuy; 0x72uy; 0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test4_input_key:lbytes 32 | [] | Spec.AES.Test.test4_input_key | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | {
"end_col": 11,
"end_line": 287,
"start_col": 33,
"start_line": 280
} |
Prims.Tot | val test4_output_ciphertext:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test4_output_ciphertext:lbytes 16
let test4_output_ciphertext:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy; 0x74uy; 0x3buy; 0x94uy; 0xd5uy;
0x00uy; 0x2auy; 0x12uy; 0x6buy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test4_output_ciphertext:lbytes 16 | [] | Spec.AES.Test.test4_output_ciphertext | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 303,
"start_col": 41,
"start_line": 298
} |
Prims.Tot | val test_plaintext:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test_plaintext:lbytes 16
let test_plaintext:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy; 0xe9uy; 0x3duy; 0x7euy; 0x11uy;
0x73uy; 0x93uy; 0x17uy; 0x2auy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_plaintext:lbytes 16 | [] | Spec.AES.Test.test_plaintext | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 36,
"start_col": 32,
"start_line": 31
} |
Prims.Tot | val test3_input_key:lbytes 32 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | val test3_input_key:lbytes 32
let test3_input_key:lbytes 32 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy; 0xecuy; 0x47uy; 0x57uy; 0xf2uy;
0x2fuy; 0xfeuy; 0xeeuy; 0x35uy; 0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test3_input_key:lbytes 32 | [] | Spec.AES.Test.test3_input_key | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | {
"end_col": 11,
"end_line": 261,
"start_col": 33,
"start_line": 254
} |
Prims.Tot | val test2_output_ciphertext:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test2_output_ciphertext:lbytes 16
let test2_output_ciphertext:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy; 0xeauy; 0xfcuy; 0x49uy; 0x90uy;
0x4buy; 0x49uy; 0x60uy; 0x89uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test2_output_ciphertext:lbytes 16 | [] | Spec.AES.Test.test2_output_ciphertext | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 251,
"start_col": 41,
"start_line": 246
} |
Prims.Tot | val test_ciphertext:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test_ciphertext:lbytes 16
let test_ciphertext:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy; 0x1buy; 0xefuy; 0x68uy; 0x64uy;
0x99uy; 0x0duy; 0xb6uy; 0xceuy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_ciphertext:lbytes 16 | [] | Spec.AES.Test.test_ciphertext | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 44,
"start_col": 33,
"start_line": 39
} |
Prims.Tot | val test1_input_key1:lbytes 32 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | val test1_input_key1:lbytes 32
let test1_input_key1:lbytes 32 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy; 0x2buy; 0x73uy; 0xaeuy; 0xf0uy;
0x85uy; 0x7duy; 0x77uy; 0x81uy; 0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test1_input_key1:lbytes 32 | [] | Spec.AES.Test.test1_input_key1 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | {
"end_col": 11,
"end_line": 188,
"start_col": 34,
"start_line": 181
} |
Prims.Tot | val test_key1:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test_key1:lbytes 16
let test_key1:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy; 0x4Buy; 0xF7uy; 0xA5uy; 0x76uy;
0x55uy; 0x77uy; 0xF3uy; 0x9Euy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_key1:lbytes 16 | [] | Spec.AES.Test.test_key1 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 52,
"start_col": 27,
"start_line": 47
} |
Prims.Tot | val test1_ciphertext_block:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test1_ciphertext_block:lbytes 16
let test1_ciphertext_block:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy; 0x45uy; 0x5buy; 0xd8uy; 0xbauy;
0x14uy; 0x18uy; 0xbeuy; 0xc8uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test1_ciphertext_block:lbytes 16 | [] | Spec.AES.Test.test1_ciphertext_block | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 138,
"start_col": 40,
"start_line": 133
} |
Prims.Tot | val test_ciphertext2:lbytes 32 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | val test_ciphertext2:lbytes 32
let test_ciphertext2:lbytes 32 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy; 0x79uy; 0x0Duy; 0x41uy; 0xEEuy;
0x8Euy; 0xDAuy; 0xD3uy; 0x88uy; 0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_ciphertext2:lbytes 32 | [] | Spec.AES.Test.test_ciphertext2 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | {
"end_col": 11,
"end_line": 114,
"start_col": 34,
"start_line": 107
} |
Prims.Tot | val test2_ciphertext_block:lbytes 16 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | val test2_ciphertext_block:lbytes 16
let test2_ciphertext_block:lbytes 16 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy; 0x91uy; 0xc5uy; 0x7duy; 0x9fuy;
0xb6uy; 0x85uy; 0x48uy; 0xd1uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test2_ciphertext_block:lbytes 16 | [] | Spec.AES.Test.test2_ciphertext_block | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | {
"end_col": 11,
"end_line": 162,
"start_col": 40,
"start_line": 157
} |
Prims.Tot | val test_plaintext2:lbytes 32 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | val test_plaintext2:lbytes 32
let test_plaintext2:lbytes 32 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0Auy; 0x0Buy;
0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1 | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_plaintext2:lbytes 32 | [] | Spec.AES.Test.test_plaintext2 | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | {
"end_col": 11,
"end_line": 104,
"start_col": 33,
"start_line": 97
} |
FStar.All.ALL | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_one_encrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> expected
| Vec_block v key plain expected -> expected in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter plain
| Vec_block v key plain expected ->
aes_encrypt_block v (aes_key_expansion v key) plain in
PS.print_compare true (length expected) computed expected | let test_one_encrypt (v: vec) = | true | null | false | let expected =
match v with
| Vec v key nonce counter plain expected -> expected
| Vec_block v key plain expected -> expected
in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter plain
| Vec_block v key plain expected -> aes_encrypt_block v (aes_key_expansion v key) plain
in
PS.print_compare true (length expected) computed expected | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [] | [
"Spec.AES.Test.vec",
"Lib.PrintSequence.print_compare",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.bool",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Spec.AES.variant",
"Spec.AES.aes_key",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.size_nat",
"Prims.op_Addition",
"Prims.op_Division",
"Lib.IntTypes.max_size_t",
"Prims.l_and",
"Prims.op_Equality",
"Prims.nat",
"Spec.AES.aes_ctr_encrypt_bytes",
"Spec.AES.block",
"Spec.AES.aes_encrypt_block",
"Spec.AES.aes_key_expansion",
"Lib.ByteSequence.lbytes",
"Lib.Sequence.seq"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n"
(*
let seqsbox_16 = map (fun s -> sbox_bp_16 s) seqi in
IO.print_string "sbox bp_i i:\n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox_16);
IO.print_string "\n";
*)
noeq type vec =
| Vec :
v:variant
-> key:aes_key v
-> nonce:bytes{length nonce <= 16}
-> c:size_nat
-> msg:bytes{length msg / 16 + c <= max_size_t}
-> expected:bytes{length msg = length expected /\ length msg <= max_size_t} -> vec
| Vec_block :
v:variant
-> key:aes_key v
-> plain:block
-> expected:block -> vec
let test_vectors : list vec = [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
]
#set-options "--ifuel 1" | false | false | Spec.AES.Test.fst | {
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_one_encrypt : v: Spec.AES.Test.vec -> FStar.All.ALL Prims.bool | [] | Spec.AES.Test.test_one_encrypt | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v: Spec.AES.Test.vec -> FStar.All.ALL Prims.bool | {
"end_col": 59,
"end_line": 371,
"start_col": 30,
"start_line": 358
} |
|
FStar.All.ALL | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test_one_decrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> plain
| Vec_block v key plain expected -> plain in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter expected
| Vec_block v key plain expected ->
aes_decrypt_block v (aes_dec_key_expansion v key) expected in
PS.print_compare true (length expected) computed expected | let test_one_decrypt (v: vec) = | true | null | false | let expected =
match v with
| Vec v key nonce counter plain expected -> plain
| Vec_block v key plain expected -> plain
in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter expected
| Vec_block v key plain expected -> aes_decrypt_block v (aes_dec_key_expansion v key) expected
in
PS.print_compare true (length expected) computed expected | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [] | [
"Spec.AES.Test.vec",
"Lib.PrintSequence.print_compare",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.bool",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Spec.AES.variant",
"Spec.AES.aes_key",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.size_nat",
"Prims.op_Addition",
"Prims.op_Division",
"Lib.IntTypes.max_size_t",
"Prims.l_and",
"Prims.op_Equality",
"Prims.nat",
"Spec.AES.aes_ctr_encrypt_bytes",
"Spec.AES.block",
"Spec.AES.aes_decrypt_block",
"Spec.AES.aes_dec_key_expansion",
"Lib.ByteSequence.lbytes",
"Lib.Sequence.seq"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n"
(*
let seqsbox_16 = map (fun s -> sbox_bp_16 s) seqi in
IO.print_string "sbox bp_i i:\n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox_16);
IO.print_string "\n";
*)
noeq type vec =
| Vec :
v:variant
-> key:aes_key v
-> nonce:bytes{length nonce <= 16}
-> c:size_nat
-> msg:bytes{length msg / 16 + c <= max_size_t}
-> expected:bytes{length msg = length expected /\ length msg <= max_size_t} -> vec
| Vec_block :
v:variant
-> key:aes_key v
-> plain:block
-> expected:block -> vec
let test_vectors : list vec = [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
]
#set-options "--ifuel 1"
let test_one_encrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> expected
| Vec_block v key plain expected -> expected in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter plain
| Vec_block v key plain expected ->
aes_encrypt_block v (aes_key_expansion v key) plain in
PS.print_compare true (length expected) computed expected | false | false | Spec.AES.Test.fst | {
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test_one_decrypt : v: Spec.AES.Test.vec -> FStar.All.ALL Prims.bool | [] | Spec.AES.Test.test_one_decrypt | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v: Spec.AES.Test.vec -> FStar.All.ALL Prims.bool | {
"end_col": 59,
"end_line": 387,
"start_col": 30,
"start_line": 374
} |
|
FStar.All.ML | val test: Prims.unit -> FStar.All.ML bool | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test() : FStar.All.ML bool =
// print_sbox (); // TODO: rm?
IO.print_string "\n\nAES Encryption\n";
let res_enc = List.for_all (fun (v:vec) -> test_one_encrypt v) test_vectors in
IO.print_string "\n\nAES Decryption\n";
let res_dec = List.for_all (fun (v:vec) -> test_one_decrypt v) test_vectors in
IO.print_string "\n\nAES Key Expansion\n";
let computed1 = aes_key_expansion AES256 test1_input_key1 in
let res_key = PS.print_compare true (length computed1) test1_output_expanded computed1 in
let res = res_enc && res_dec && res_key in
if res then begin IO.print_string "\n\nAES: Success!\n"; true end
else begin IO.print_string "\n\nAES: Failure :(\n"; false end | val test: Prims.unit -> FStar.All.ML bool
let test () : FStar.All.ML bool = | true | null | false | IO.print_string "\n\nAES Encryption\n";
let res_enc = List.for_all (fun (v: vec) -> test_one_encrypt v) test_vectors in
IO.print_string "\n\nAES Decryption\n";
let res_dec = List.for_all (fun (v: vec) -> test_one_decrypt v) test_vectors in
IO.print_string "\n\nAES Key Expansion\n";
let computed1 = aes_key_expansion AES256 test1_input_key1 in
let res_key = PS.print_compare true (length computed1) test1_output_expanded computed1 in
let res = res_enc && res_dec && res_key in
if res
then
(IO.print_string "\n\nAES: Success!\n";
true)
else
(IO.print_string "\n\nAES: Failure :(\n";
false) | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"ml"
] | [
"Prims.unit",
"Prims.bool",
"FStar.IO.print_string",
"Prims.op_AmpAmp",
"Lib.PrintSequence.print_compare",
"Lib.Sequence.length",
"Spec.AES.elem",
"Spec.AES.Test.test1_output_expanded",
"Spec.AES.aes_xkey",
"Spec.AES.AES256",
"Spec.AES.aes_key_expansion",
"Spec.AES.Test.test1_input_key1",
"FStar.List.for_all",
"Spec.AES.Test.vec",
"Spec.AES.Test.test_one_decrypt",
"Spec.AES.Test.test_vectors",
"Spec.AES.Test.test_one_encrypt"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n"
(*
let seqsbox_16 = map (fun s -> sbox_bp_16 s) seqi in
IO.print_string "sbox bp_i i:\n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox_16);
IO.print_string "\n";
*)
noeq type vec =
| Vec :
v:variant
-> key:aes_key v
-> nonce:bytes{length nonce <= 16}
-> c:size_nat
-> msg:bytes{length msg / 16 + c <= max_size_t}
-> expected:bytes{length msg = length expected /\ length msg <= max_size_t} -> vec
| Vec_block :
v:variant
-> key:aes_key v
-> plain:block
-> expected:block -> vec
let test_vectors : list vec = [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
]
#set-options "--ifuel 1"
let test_one_encrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> expected
| Vec_block v key plain expected -> expected in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter plain
| Vec_block v key plain expected ->
aes_encrypt_block v (aes_key_expansion v key) plain in
PS.print_compare true (length expected) computed expected
let test_one_decrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> plain
| Vec_block v key plain expected -> plain in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter expected
| Vec_block v key plain expected ->
aes_decrypt_block v (aes_dec_key_expansion v key) expected in
PS.print_compare true (length expected) computed expected
let test() : FStar.All.ML bool =
// print_sbox (); // TODO: rm? | false | false | Spec.AES.Test.fst | {
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test: Prims.unit -> FStar.All.ML bool | [] | Spec.AES.Test.test | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 63,
"end_line": 403,
"start_col": 2,
"start_line": 393
} |
Prims.Tot | val test1_output_expanded:lbytes 240 | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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
}
] | false | let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l | val test1_output_expanded:lbytes 240
let test1_output_expanded:lbytes 240 = | false | null | false | let l =
List.Tot.map u8_from_UInt8
[
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy; 0x2buy; 0x73uy; 0xaeuy; 0xf0uy;
0x85uy; 0x7duy; 0x77uy; 0x81uy; 0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy; 0x9buy; 0xa3uy; 0x54uy; 0x11uy;
0x8euy; 0x69uy; 0x25uy; 0xafuy; 0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy; 0xbeuy; 0x49uy; 0x84uy; 0x6euy;
0xb7uy; 0x5duy; 0x5buy; 0x9auy; 0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy; 0xb5uy; 0xa9uy; 0x32uy; 0x8auy;
0x26uy; 0x78uy; 0xa6uy; 0x47uy; 0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy; 0x24uy; 0x36uy; 0x0auy; 0xf2uy;
0xfauy; 0xb8uy; 0xb4uy; 0x64uy; 0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy; 0x68uy; 0x00uy; 0x7buy; 0xacuy;
0xb2uy; 0xdfuy; 0x33uy; 0x16uy; 0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy; 0x50uy; 0x25uy; 0xc0uy; 0x2duy;
0x59uy; 0xc5uy; 0x82uy; 0x39uy; 0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy; 0x58uy; 0x86uy; 0xcauy; 0x5duy;
0x2euy; 0x2fuy; 0x31uy; 0xd7uy; 0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy; 0xe2uy; 0x75uy; 0x7euy; 0x4fuy;
0x74uy; 0x01uy; 0x90uy; 0x5auy; 0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy; 0xfeuy; 0x48uy; 0x90uy; 0xd1uy;
0xe6uy; 0x18uy; 0x8duy; 0x0buy; 0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
]
in
assert_norm (List.Tot.length l == 240);
of_list l | {
"checked_file": "Spec.AES.Test.fst.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
"total"
] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | false | false | Spec.AES.Test.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val test1_output_expanded:lbytes 240 | [] | Spec.AES.Test.test1_output_expanded | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 240 | {
"end_col": 11,
"end_line": 225,
"start_col": 40,
"start_line": 191
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sint_v #t #l (u:sint_t t l) = v u | let sint_v #t #l (u: sint_t t l) = | false | null | false | v u | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.signed",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.sint_t",
"Lib.IntTypes.v",
"Prims.int",
"Lib.IntTypes.range"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sint_v : u48: Lib.IntTypes.sint_t t l -> x: Prims.int{Lib.IntTypes.range x t} | [] | Lib.IntTypes.sint_v | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | u48: Lib.IntTypes.sint_t t l -> x: Prims.int{Lib.IntTypes.range x t} | {
"end_col": 37,
"end_line": 167,
"start_col": 34,
"start_line": 167
} |
|
Prims.Tot | val u16 (n: range_t U16) : u: uint16{v u == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n | val u16 (n: range_t U16) : u: uint16{v u == n}
let u16 (n: range_t U16) : u: uint16{v u == n} = | false | null | false | uint #U16 #SEC n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint16",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16 (n: range_t U16) : u: uint16{v u == n} | [] | Lib.IntTypes.u16 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t Lib.IntTypes.U16 -> u57: Lib.IntTypes.uint16{Lib.IntTypes.v u57 == n} | {
"end_col": 63,
"end_line": 280,
"start_col": 47,
"start_line": 280
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false | let unsigned = | false | null | false | function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.bool"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val unsigned : _: Lib.IntTypes.inttype -> Prims.bool | [] | Lib.IntTypes.unsigned | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.inttype -> Prims.bool | {
"end_col": 14,
"end_line": 26,
"start_col": 15,
"start_line": 24
} |
|
Prims.Tot | val u64 (n: range_t U64) : u: uint64{v u == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n | val u64 (n: range_t U64) : u: uint64{v u == n}
let u64 (n: range_t U64) : u: uint64{v u == n} = | false | null | false | uint #U64 #SEC n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint64",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64 (n: range_t U64) : u: uint64{v u == n} | [] | Lib.IntTypes.u64 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t Lib.IntTypes.U64 -> u61: Lib.IntTypes.uint64{Lib.IntTypes.v u61 == n} | {
"end_col": 63,
"end_line": 292,
"start_col": 47,
"start_line": 292
} |
Prims.Tot | val i32 (n: range_t S32) : u: int32{v u == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n | val i32 (n: range_t S32) : u: int32{v u == n}
let i32 (n: range_t S32) : u: int32{v u == n} = | false | null | false | sint #S32 #SEC n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.S32",
"Lib.IntTypes.sint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int32",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val i32 (n: range_t S32) : u: int32{v u == n} | [] | Lib.IntTypes.i32 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t Lib.IntTypes.S32 -> u60: Lib.IntTypes.int32{Lib.IntTypes.v u60 == n} | {
"end_col": 62,
"end_line": 289,
"start_col": 46,
"start_line": 289
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_v #t #l (u:uint_t t l) = v u | let uint_v #t #l (u: uint_t t l) = | false | null | false | v u | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.v",
"Prims.int",
"Lib.IntTypes.range"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint_v : u45: Lib.IntTypes.uint_t t l -> x: Prims.int{Lib.IntTypes.range x t} | [] | Lib.IntTypes.uint_v | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | u45: Lib.IntTypes.uint_t t l -> x: Prims.int{Lib.IntTypes.range x t} | {
"end_col": 37,
"end_line": 164,
"start_col": 34,
"start_line": 164
} |
|
Prims.Tot | val u32 (n: range_t U32) : u: uint32{v u == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n | val u32 (n: range_t U32) : u: uint32{v u == n}
let u32 (n: range_t U32) : u: uint32{v u == n} = | false | null | false | uint #U32 #SEC n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint32",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32 (n: range_t U32) : u: uint32{v u == n} | [] | Lib.IntTypes.u32 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t Lib.IntTypes.U32 -> u59: Lib.IntTypes.uint32{Lib.IntTypes.v u59 == n} | {
"end_col": 63,
"end_line": 286,
"start_col": 47,
"start_line": 286
} |
Prims.Tot | val u8 (n: range_t U8) : u: uint8{v u == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n | val u8 (n: range_t U8) : u: uint8{v u == n}
let u8 (n: range_t U8) : u: uint8{v u == n} = | false | null | false | uint #U8 #SEC n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint8",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8 (n: range_t U8) : u: uint8{v u == n} | [] | Lib.IntTypes.u8 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t Lib.IntTypes.U8 -> u55: Lib.IntTypes.uint8{Lib.IntTypes.v u55 == n} | {
"end_col": 59,
"end_line": 274,
"start_col": 44,
"start_line": 274
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let max_size_t = maxint U32 | let max_size_t = | false | null | false | maxint U32 | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.maxint",
"Lib.IntTypes.U32"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n} | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val max_size_t : Prims.int | [] | Lib.IntTypes.max_size_t | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.int | {
"end_col": 27,
"end_line": 305,
"start_col": 17,
"start_line": 305
} |
|
Prims.Tot | val i16 (n: range_t S16) : u: int16{v u == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n | val i16 (n: range_t S16) : u: int16{v u == n}
let i16 (n: range_t S16) : u: int16{v u == n} = | false | null | false | sint #S16 #SEC n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.S16",
"Lib.IntTypes.sint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int16",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val i16 (n: range_t S16) : u: int16{v u == n} | [] | Lib.IntTypes.i16 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t Lib.IntTypes.S16 -> u58: Lib.IntTypes.int16{Lib.IntTypes.v u58 == n} | {
"end_col": 62,
"end_line": 283,
"start_col": 46,
"start_line": 283
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l | let sint_t (t: inttype{signed t}) (l: secrecy_level) = | false | null | false | int_t t l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.signed",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.int_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sint_t : t: Lib.IntTypes.inttype{Lib.IntTypes.signed t} -> l: Lib.IntTypes.secrecy_level -> Type0 | [] | Lib.IntTypes.sint_t | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntTypes.inttype{Lib.IntTypes.signed t} -> l: Lib.IntTypes.secrecy_level -> Type0 | {
"end_col": 62,
"end_line": 161,
"start_col": 53,
"start_line": 161
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false | let signed = | false | null | false | function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.bool"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val signed : _: Lib.IntTypes.inttype -> Prims.bool | [] | Lib.IntTypes.signed | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.inttype -> Prims.bool | {
"end_col": 14,
"end_line": 33,
"start_col": 13,
"start_line": 31
} |
|
Prims.Tot | val i64 (n: range_t S64) : u: int64{v u == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n | val i64 (n: range_t S64) : u: int64{v u == n}
let i64 (n: range_t S64) : u: int64{v u == n} = | false | null | false | sint #S64 #SEC n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.S64",
"Lib.IntTypes.sint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int64",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val i64 (n: range_t S64) : u: int64{v u == n} | [] | Lib.IntTypes.i64 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t Lib.IntTypes.S64 -> u62: Lib.IntTypes.int64{Lib.IntTypes.v u62 == n} | {
"end_col": 62,
"end_line": 295,
"start_col": 46,
"start_line": 295
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l | let uint_t (t: inttype{unsigned t}) (l: secrecy_level) = | false | null | false | int_t t l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.int_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint_t : t: Lib.IntTypes.inttype{Lib.IntTypes.unsigned t} -> l: Lib.IntTypes.secrecy_level -> Type0 | [] | Lib.IntTypes.uint_t | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntTypes.inttype{Lib.IntTypes.unsigned t} -> l: Lib.IntTypes.secrecy_level -> Type0 | {
"end_col": 64,
"end_line": 158,
"start_col": 55,
"start_line": 158
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let size_v (s:size_t) = v s | let size_v (s: size_t) = | false | null | false | v s | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.int",
"Lib.IntTypes.range"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size_v : s: Lib.IntTypes.size_t -> x: Prims.int{Lib.IntTypes.range x Lib.IntTypes.U32} | [] | Lib.IntTypes.size_v | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Lib.IntTypes.size_t -> x: Prims.int{Lib.IntTypes.range x Lib.IntTypes.U32} | {
"end_col": 27,
"end_line": 317,
"start_col": 24,
"start_line": 317
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( ~. ) #t #l = lognot #t #l | let op_Tilde_Dot #t #l = | false | null | false | lognot #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.lognot",
"Lib.IntTypes.int_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l
unfold
let ( &. ) #t #l = logand #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Tilde_Dot : _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Tilde_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | {
"end_col": 31,
"end_line": 870,
"start_col": 19,
"start_line": 870
} |
|
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( <<. ) #t #l = shift_left #t #l | let op_Less_Less_Dot #t #l = | false | null | false | shift_left #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.shift_left",
"Lib.IntTypes.int_t",
"Lib.IntTypes.shiftval",
"Prims.l_or",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Prims.op_Multiply",
"Prims.pow2",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.maxint",
"Prims.l_True"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Less_Dot : a: Lib.IntTypes.int_t t l -> s: Lib.IntTypes.shiftval t -> Prims.Pure (Lib.IntTypes.int_t t l) | [] | Lib.IntTypes.op_Less_Less_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.IntTypes.int_t t l -> s: Lib.IntTypes.shiftval t -> Prims.Pure (Lib.IntTypes.int_t t l) | {
"end_col": 36,
"end_line": 852,
"start_col": 20,
"start_line": 852
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (<>.) #t = ne #t | let op_Less_Greater_Dot #t = | false | null | false | ne #t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.ne",
"Lib.IntTypes.int_t",
"Lib.IntTypes.PUB",
"Prims.bool"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l
unfold
let ( &. ) #t #l = logand #t #l
unfold
let ( ~. ) #t #l = lognot #t #l
///
/// Operations on public integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val div: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val div_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (v (div a b) == FStar.Int.(v a / v b))
[SMTPat (v #t (div #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mod: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val mod_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (if signed t then
v (mod a b) == FStar.Int.mod #(bits t) (v a) (v b)
else
v (mod a b) == FStar.UInt.mod #(bits t) (v a) (v b))
[SMTPat (v #t (mod #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val eq: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
inline_for_extraction
val eq_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `eq` b == (v a = v b))
[SMTPat (eq #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val ne: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val ne_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `ne` b == (v a <> v b))
[SMTPat (ne #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lt` b == (v a < v b))
[SMTPat (lt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lte` b == (v a <= v b))
[SMTPat (lte #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gt` b == (v a > v b))
[SMTPat (gt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gte` b == (v a >= v b))
[SMTPat (gte #t a b)]
unfold
let (/.) #t = div #t
unfold
let (%.) #t = mod #t
unfold
let (=.) #t = eq #t | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Greater_Dot : _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | [] | Lib.IntTypes.op_Less_Greater_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | {
"end_col": 20,
"end_line": 976,
"start_col": 15,
"start_line": 976
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n | let uint (#t: inttype{unsigned t}) (#l: secrecy_level) (n: range_t t) = | false | null | false | mk_int #t #l n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.range_t",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n} | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint : n: Lib.IntTypes.range_t t -> u52: Lib.IntTypes.int_t t l {Lib.IntTypes.v u52 == n} | [] | Lib.IntTypes.uint | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t t -> u52: Lib.IntTypes.int_t t l {Lib.IntTypes.v u52 == n} | {
"end_col": 83,
"end_line": 257,
"start_col": 69,
"start_line": 257
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (+!) #t #l = add #t #l | let op_Plus_Bang #t #l = | false | null | false | add #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.add",
"Lib.IntTypes.int_t",
"Lib.IntTypes.range",
"Prims.op_Addition",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
/// | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Plus_Bang : a: Lib.IntTypes.int_t t l ->
b: Lib.IntTypes.int_t t l {Lib.IntTypes.range (Lib.IntTypes.v a + Lib.IntTypes.v b) t}
-> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Plus_Bang | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Lib.IntTypes.int_t t l ->
b: Lib.IntTypes.int_t t l {Lib.IntTypes.range (Lib.IntTypes.v a + Lib.IntTypes.v b) t}
-> Lib.IntTypes.int_t t l | {
"end_col": 26,
"end_line": 831,
"start_col": 17,
"start_line": 831
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (<.) #t = lt #t | let op_Less_Dot #t = | false | null | false | lt #t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.lt",
"Lib.IntTypes.int_t",
"Lib.IntTypes.PUB",
"Prims.bool"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l
unfold
let ( &. ) #t #l = logand #t #l
unfold
let ( ~. ) #t #l = lognot #t #l
///
/// Operations on public integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val div: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val div_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (v (div a b) == FStar.Int.(v a / v b))
[SMTPat (v #t (div #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mod: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val mod_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (if signed t then
v (mod a b) == FStar.Int.mod #(bits t) (v a) (v b)
else
v (mod a b) == FStar.UInt.mod #(bits t) (v a) (v b))
[SMTPat (v #t (mod #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val eq: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
inline_for_extraction
val eq_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `eq` b == (v a = v b))
[SMTPat (eq #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val ne: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val ne_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `ne` b == (v a <> v b))
[SMTPat (ne #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lt` b == (v a < v b))
[SMTPat (lt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lte` b == (v a <= v b))
[SMTPat (lte #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gt` b == (v a > v b))
[SMTPat (gt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gte` b == (v a >= v b))
[SMTPat (gte #t a b)]
unfold
let (/.) #t = div #t
unfold
let (%.) #t = mod #t
unfold
let (=.) #t = eq #t
unfold
let (<>.) #t = ne #t | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Dot : _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | [] | Lib.IntTypes.op_Less_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | {
"end_col": 19,
"end_line": 979,
"start_col": 14,
"start_line": 979
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( ^. ) #t #l = logxor #t #l | let op_Hat_Dot #t #l = | false | null | false | logxor #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.logxor",
"Lib.IntTypes.int_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Hat_Dot : _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Hat_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | {
"end_col": 31,
"end_line": 861,
"start_col": 19,
"start_line": 861
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( >>. ) #t #l = shift_right #t #l | let op_Greater_Greater_Dot #t #l = | false | null | false | shift_right #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.shift_right",
"Lib.IntTypes.int_t",
"Lib.IntTypes.shiftval"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater_Greater_Dot : _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.shiftval t -> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Greater_Greater_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.shiftval t -> Lib.IntTypes.int_t t l | {
"end_col": 37,
"end_line": 849,
"start_col": 20,
"start_line": 849
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (=.) #t = eq #t | let op_Equals_Dot #t = | false | null | false | eq #t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.eq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.PUB",
"Prims.bool"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l
unfold
let ( &. ) #t #l = logand #t #l
unfold
let ( ~. ) #t #l = lognot #t #l
///
/// Operations on public integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val div: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val div_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (v (div a b) == FStar.Int.(v a / v b))
[SMTPat (v #t (div #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mod: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val mod_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (if signed t then
v (mod a b) == FStar.Int.mod #(bits t) (v a) (v b)
else
v (mod a b) == FStar.UInt.mod #(bits t) (v a) (v b))
[SMTPat (v #t (mod #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val eq: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
inline_for_extraction
val eq_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `eq` b == (v a = v b))
[SMTPat (eq #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val ne: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val ne_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `ne` b == (v a <> v b))
[SMTPat (ne #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lt` b == (v a < v b))
[SMTPat (lt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lte` b == (v a <= v b))
[SMTPat (lte #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gt` b == (v a > v b))
[SMTPat (gt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gte` b == (v a >= v b))
[SMTPat (gte #t a b)]
unfold
let (/.) #t = div #t
unfold
let (%.) #t = mod #t | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Equals_Dot : _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | [] | Lib.IntTypes.op_Equals_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | {
"end_col": 19,
"end_line": 973,
"start_col": 14,
"start_line": 973
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (>.) #t = gt #t | let op_Greater_Dot #t = | false | null | false | gt #t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.gt",
"Lib.IntTypes.int_t",
"Lib.IntTypes.PUB",
"Prims.bool"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l
unfold
let ( &. ) #t #l = logand #t #l
unfold
let ( ~. ) #t #l = lognot #t #l
///
/// Operations on public integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val div: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val div_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (v (div a b) == FStar.Int.(v a / v b))
[SMTPat (v #t (div #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mod: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val mod_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (if signed t then
v (mod a b) == FStar.Int.mod #(bits t) (v a) (v b)
else
v (mod a b) == FStar.UInt.mod #(bits t) (v a) (v b))
[SMTPat (v #t (mod #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val eq: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
inline_for_extraction
val eq_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `eq` b == (v a = v b))
[SMTPat (eq #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val ne: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val ne_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `ne` b == (v a <> v b))
[SMTPat (ne #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lt` b == (v a < v b))
[SMTPat (lt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lte` b == (v a <= v b))
[SMTPat (lte #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gt` b == (v a > v b))
[SMTPat (gt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gte` b == (v a >= v b))
[SMTPat (gte #t a b)]
unfold
let (/.) #t = div #t
unfold
let (%.) #t = mod #t
unfold
let (=.) #t = eq #t
unfold
let (<>.) #t = ne #t
unfold
let (<.) #t = lt #t
unfold
let (<=.) #t = lte #t | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater_Dot : _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | [] | Lib.IntTypes.op_Greater_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | {
"end_col": 19,
"end_line": 985,
"start_col": 14,
"start_line": 985
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (%.) #t = mod #t | let op_Percent_Dot #t = | false | null | false | mod #t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_and",
"Prims.l_not",
"Prims.b2t",
"Lib.IntTypes.uu___is_U128",
"Lib.IntTypes.uu___is_S128",
"Lib.IntTypes.mod",
"Lib.IntTypes.int_t",
"Lib.IntTypes.PUB",
"Prims.op_disEquality",
"Prims.int",
"Lib.IntTypes.v",
"Prims.l_or",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.range",
"FStar.Int.op_Slash"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l
unfold
let ( &. ) #t #l = logand #t #l
unfold
let ( ~. ) #t #l = lognot #t #l
///
/// Operations on public integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val div: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val div_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (v (div a b) == FStar.Int.(v a / v b))
[SMTPat (v #t (div #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mod: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val mod_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (if signed t then
v (mod a b) == FStar.Int.mod #(bits t) (v a) (v b)
else
v (mod a b) == FStar.UInt.mod #(bits t) (v a) (v b))
[SMTPat (v #t (mod #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val eq: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
inline_for_extraction
val eq_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `eq` b == (v a = v b))
[SMTPat (eq #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val ne: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val ne_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `ne` b == (v a <> v b))
[SMTPat (ne #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lt` b == (v a < v b))
[SMTPat (lt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lte` b == (v a <= v b))
[SMTPat (lte #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gt` b == (v a > v b))
[SMTPat (gt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gte` b == (v a >= v b))
[SMTPat (gte #t a b)]
unfold
let (/.) #t = div #t | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Percent_Dot : a: Lib.IntTypes.int_t t Lib.IntTypes.PUB ->
b:
Lib.IntTypes.int_t t Lib.IntTypes.PUB
{ Lib.IntTypes.v b <> 0 /\
(Lib.IntTypes.unsigned t \/ Lib.IntTypes.range (Lib.IntTypes.v a / Lib.IntTypes.v b) t) }
-> Lib.IntTypes.int_t t Lib.IntTypes.PUB | [] | Lib.IntTypes.op_Percent_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Lib.IntTypes.int_t t Lib.IntTypes.PUB ->
b:
Lib.IntTypes.int_t t Lib.IntTypes.PUB
{ Lib.IntTypes.v b <> 0 /\
(Lib.IntTypes.unsigned t \/ Lib.IntTypes.range (Lib.IntTypes.v a / Lib.IntTypes.v b) t) }
-> Lib.IntTypes.int_t t Lib.IntTypes.PUB | {
"end_col": 20,
"end_line": 970,
"start_col": 14,
"start_line": 970
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( -. ) #t #l = sub_mod #t #l | let op_Subtraction_Dot #t #l = | false | null | false | sub_mod #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.sub_mod",
"Lib.IntTypes.int_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Subtraction_Dot : _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Subtraction_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | {
"end_col": 32,
"end_line": 846,
"start_col": 19,
"start_line": 846
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( >>>. ) #t #l = rotate_right #t #l | let op_Greater_Greater_Greater_Dot #t #l = | false | null | false | rotate_right #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.rotate_right",
"Lib.IntTypes.int_t",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.rotval"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater_Greater_Greater_Dot : a: Lib.IntTypes.int_t t l {Lib.IntTypes.unsigned t} -> _: Lib.IntTypes.rotval t
-> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Greater_Greater_Greater_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.IntTypes.int_t t l {Lib.IntTypes.unsigned t} -> _: Lib.IntTypes.rotval t
-> Lib.IntTypes.int_t t l | {
"end_col": 39,
"end_line": 855,
"start_col": 21,
"start_line": 855
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( -! ) #t #l = sub #t #l | let op_Subtraction_Bang #t #l = | false | null | false | sub #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.sub",
"Lib.IntTypes.int_t",
"Lib.IntTypes.range",
"Prims.op_Subtraction",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Subtraction_Bang : a: Lib.IntTypes.int_t t l ->
b: Lib.IntTypes.int_t t l {Lib.IntTypes.range (Lib.IntTypes.v a - Lib.IntTypes.v b) t}
-> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Subtraction_Bang | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Lib.IntTypes.int_t t l ->
b: Lib.IntTypes.int_t t l {Lib.IntTypes.range (Lib.IntTypes.v a - Lib.IntTypes.v b) t}
-> Lib.IntTypes.int_t t l | {
"end_col": 28,
"end_line": 843,
"start_col": 19,
"start_line": 843
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n | let sint (#t: inttype{signed t}) (#l: secrecy_level) (n: range_t t) = | false | null | false | mk_int #t #l n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.signed",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.range_t",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sint : n: Lib.IntTypes.range_t t -> u55: Lib.IntTypes.int_t t l {Lib.IntTypes.v u55 == n} | [] | Lib.IntTypes.sint | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t t -> u55: Lib.IntTypes.int_t t l {Lib.IntTypes.v u55 == n} | {
"end_col": 81,
"end_line": 260,
"start_col": 67,
"start_line": 260
} |
|
Prims.Tot | val i8 (n: range_t S8) : u: int8{v u == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n | val i8 (n: range_t S8) : u: int8{v u == n}
let i8 (n: range_t S8) : u: int8{v u == n} = | false | null | false | sint #S8 #SEC n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.S8",
"Lib.IntTypes.sint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int8",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val i8 (n: range_t S8) : u: int8{v u == n} | [] | Lib.IntTypes.i8 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t Lib.IntTypes.S8 -> u56: Lib.IntTypes.int8{Lib.IntTypes.v u56 == n} | {
"end_col": 58,
"end_line": 277,
"start_col": 43,
"start_line": 277
} |
Prims.Tot | val u1 (n: range_t U1) : u: uint1{v u == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n | val u1 (n: range_t U1) : u: uint1{v u == n}
let u1 (n: range_t U1) : u: uint1{v u == n} = | false | null | false | uint #U1 #SEC n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U1",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint1",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))] | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u1 (n: range_t U1) : u: uint1{v u == n} | [] | Lib.IntTypes.u1 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.range_t Lib.IntTypes.U1 -> u54: Lib.IntTypes.uint1{Lib.IntTypes.v u54 == n} | {
"end_col": 59,
"end_line": 271,
"start_col": 44,
"start_line": 271
} |
Prims.Tot | val range (n: int) (t: inttype) : Type0 | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t | val range (n: int) (t: inttype) : Type0
let range (n: int) (t: inttype) : Type0 = | false | null | false | minint t <= n /\ n <= maxint t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Prims.int",
"Lib.IntTypes.inttype",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.minint",
"Lib.IntTypes.maxint"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1)) | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val range (n: int) (t: inttype) : Type0 | [] | Lib.IntTypes.range | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Prims.int -> t: Lib.IntTypes.inttype -> Type0 | {
"end_col": 32,
"end_line": 88,
"start_col": 2,
"start_line": 88
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (+.) #t #l = add_mod #t #l | let op_Plus_Dot #t #l = | false | null | false | add_mod #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.add_mod",
"Lib.IntTypes.int_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Plus_Dot : _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Plus_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | {
"end_col": 30,
"end_line": 834,
"start_col": 17,
"start_line": 834
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( *! ) #t #l = mul #t #l | let op_Star_Bang #t #l = | false | null | false | mul #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_and",
"Prims.l_not",
"Prims.b2t",
"Lib.IntTypes.uu___is_U128",
"Lib.IntTypes.uu___is_S128",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.mul",
"Lib.IntTypes.int_t",
"Lib.IntTypes.range",
"Prims.op_Multiply",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Star_Bang : a: Lib.IntTypes.int_t t l ->
b: Lib.IntTypes.int_t t l {Lib.IntTypes.range (Lib.IntTypes.v a * Lib.IntTypes.v b) t}
-> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Star_Bang | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Lib.IntTypes.int_t t l ->
b: Lib.IntTypes.int_t t l {Lib.IntTypes.range (Lib.IntTypes.v a * Lib.IntTypes.v b) t}
-> Lib.IntTypes.int_t t l | {
"end_col": 28,
"end_line": 837,
"start_col": 19,
"start_line": 837
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( <<<. ) #t #l = rotate_left #t #l | let op_Less_Less_Less_Dot #t #l = | false | null | false | rotate_left #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.rotate_left",
"Lib.IntTypes.int_t",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.rotval"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Less_Less_Dot : a: Lib.IntTypes.int_t t l {Lib.IntTypes.unsigned t} -> _: Lib.IntTypes.rotval t
-> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Less_Less_Less_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.IntTypes.int_t t l {Lib.IntTypes.unsigned t} -> _: Lib.IntTypes.rotval t
-> Lib.IntTypes.int_t t l | {
"end_col": 38,
"end_line": 858,
"start_col": 21,
"start_line": 858
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( *. ) #t #l = mul_mod #t #l | let op_Star_Dot #t #l = | false | null | false | mul_mod #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_and",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Prims.l_not",
"Lib.IntTypes.uu___is_U128",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.mul_mod",
"Lib.IntTypes.int_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Star_Dot : _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Star_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | {
"end_col": 32,
"end_line": 840,
"start_col": 19,
"start_line": 840
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( |. ) #t #l = logor #t #l | let op_Bar_Dot #t #l = | false | null | false | logor #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.logor",
"Lib.IntTypes.int_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Bar_Dot : _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Bar_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | {
"end_col": 30,
"end_line": 864,
"start_col": 19,
"start_line": 864
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (>=.) #t = gte #t | let op_Greater_Equals_Dot #t = | false | null | false | gte #t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.gte",
"Lib.IntTypes.int_t",
"Lib.IntTypes.PUB",
"Prims.bool"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l
unfold
let ( &. ) #t #l = logand #t #l
unfold
let ( ~. ) #t #l = lognot #t #l
///
/// Operations on public integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val div: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val div_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (v (div a b) == FStar.Int.(v a / v b))
[SMTPat (v #t (div #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mod: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val mod_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (if signed t then
v (mod a b) == FStar.Int.mod #(bits t) (v a) (v b)
else
v (mod a b) == FStar.UInt.mod #(bits t) (v a) (v b))
[SMTPat (v #t (mod #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val eq: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
inline_for_extraction
val eq_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `eq` b == (v a = v b))
[SMTPat (eq #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val ne: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val ne_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `ne` b == (v a <> v b))
[SMTPat (ne #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lt` b == (v a < v b))
[SMTPat (lt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lte` b == (v a <= v b))
[SMTPat (lte #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gt` b == (v a > v b))
[SMTPat (gt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gte` b == (v a >= v b))
[SMTPat (gte #t a b)]
unfold
let (/.) #t = div #t
unfold
let (%.) #t = mod #t
unfold
let (=.) #t = eq #t
unfold
let (<>.) #t = ne #t
unfold
let (<.) #t = lt #t
unfold
let (<=.) #t = lte #t
unfold
let (>.) #t = gt #t | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater_Equals_Dot : _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | [] | Lib.IntTypes.op_Greater_Equals_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | {
"end_col": 21,
"end_line": 988,
"start_col": 15,
"start_line": 988
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (/.) #t = div #t | let op_Slash_Dot #t = | false | null | false | div #t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_and",
"Prims.l_not",
"Prims.b2t",
"Lib.IntTypes.uu___is_U128",
"Lib.IntTypes.uu___is_S128",
"Lib.IntTypes.div",
"Lib.IntTypes.int_t",
"Lib.IntTypes.PUB",
"Prims.op_disEquality",
"Prims.int",
"Lib.IntTypes.v",
"Prims.l_or",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.range",
"FStar.Int.op_Slash"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l
unfold
let ( &. ) #t #l = logand #t #l
unfold
let ( ~. ) #t #l = lognot #t #l
///
/// Operations on public integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val div: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val div_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (v (div a b) == FStar.Int.(v a / v b))
[SMTPat (v #t (div #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mod: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val mod_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (if signed t then
v (mod a b) == FStar.Int.mod #(bits t) (v a) (v b)
else
v (mod a b) == FStar.UInt.mod #(bits t) (v a) (v b))
[SMTPat (v #t (mod #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val eq: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
inline_for_extraction
val eq_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `eq` b == (v a = v b))
[SMTPat (eq #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val ne: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val ne_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `ne` b == (v a <> v b))
[SMTPat (ne #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lt` b == (v a < v b))
[SMTPat (lt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lte` b == (v a <= v b))
[SMTPat (lte #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gt` b == (v a > v b))
[SMTPat (gt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gte` b == (v a >= v b))
[SMTPat (gte #t a b)] | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Slash_Dot : a: Lib.IntTypes.int_t t Lib.IntTypes.PUB ->
b:
Lib.IntTypes.int_t t Lib.IntTypes.PUB
{ Lib.IntTypes.v b <> 0 /\
(Lib.IntTypes.unsigned t \/ Lib.IntTypes.range (Lib.IntTypes.v a / Lib.IntTypes.v b) t) }
-> Lib.IntTypes.int_t t Lib.IntTypes.PUB | [] | Lib.IntTypes.op_Slash_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Lib.IntTypes.int_t t Lib.IntTypes.PUB ->
b:
Lib.IntTypes.int_t t Lib.IntTypes.PUB
{ Lib.IntTypes.v b <> 0 /\
(Lib.IntTypes.unsigned t \/ Lib.IntTypes.range (Lib.IntTypes.v a / Lib.IntTypes.v b) t) }
-> Lib.IntTypes.int_t t Lib.IntTypes.PUB | {
"end_col": 20,
"end_line": 967,
"start_col": 14,
"start_line": 967
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (<=.) #t = lte #t | let op_Less_Equals_Dot #t = | false | null | false | lte #t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.lte",
"Lib.IntTypes.int_t",
"Lib.IntTypes.PUB",
"Prims.bool"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l
unfold
let ( &. ) #t #l = logand #t #l
unfold
let ( ~. ) #t #l = lognot #t #l
///
/// Operations on public integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val div: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val div_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (v (div a b) == FStar.Int.(v a / v b))
[SMTPat (v #t (div #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mod: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> int_t t PUB
val mod_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)}
-> a:int_t t PUB
-> b:int_t t PUB{v b <> 0 /\ (unsigned t \/ range FStar.Int.(v a / v b) t)}
-> Lemma (if signed t then
v (mod a b) == FStar.Int.mod #(bits t) (v a) (v b)
else
v (mod a b) == FStar.UInt.mod #(bits t) (v a) (v b))
[SMTPat (v #t (mod #t a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val eq: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
inline_for_extraction
val eq_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `eq` b == (v a = v b))
[SMTPat (eq #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val ne: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val ne_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `ne` b == (v a <> v b))
[SMTPat (ne #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lt` b == (v a < v b))
[SMTPat (lt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val lte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `lte` b == (v a <= v b))
[SMTPat (lte #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gt_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gt` b == (v a > v b))
[SMTPat (gt #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte: #t:inttype -> int_t t PUB -> int_t t PUB -> bool
val gte_lemma: #t:inttype
-> a:int_t t PUB
-> b:int_t t PUB
-> Lemma (a `gte` b == (v a >= v b))
[SMTPat (gte #t a b)]
unfold
let (/.) #t = div #t
unfold
let (%.) #t = mod #t
unfold
let (=.) #t = eq #t
unfold
let (<>.) #t = ne #t
unfold
let (<.) #t = lt #t | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Equals_Dot : _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | [] | Lib.IntTypes.op_Less_Equals_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> _: Lib.IntTypes.int_t t Lib.IntTypes.PUB -> Prims.bool | {
"end_col": 21,
"end_line": 982,
"start_col": 15,
"start_line": 982
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( &. ) #t #l = logand #t #l | let op_Amp_Dot #t #l = | false | null | false | logand #t #l | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.logand",
"Lib.IntTypes.int_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])]
inline_for_extraction
let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1
#pop-options
val mod_mask_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l -> m:shiftval t{pow2 (uint_v m) <= maxint t}
-> Lemma (v (a `logand` mod_mask m) == v a % pow2 (v m))
[SMTPat (a `logand` mod_mask #t m)]
(** Casts a value between two signed types using modular reduction *)
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast_mod: #t:inttype{signed t} -> #l:secrecy_level
-> t':inttype{signed t'}
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> a:int_t t l
-> b:int_t t' l'{v b == v a @%. t'}
///
/// Operators available for all machine integers
///
unfold
let (+!) #t #l = add #t #l
unfold
let (+.) #t #l = add_mod #t #l
unfold
let ( *! ) #t #l = mul #t #l
unfold
let ( *. ) #t #l = mul_mod #t #l
unfold
let ( -! ) #t #l = sub #t #l
unfold
let ( -. ) #t #l = sub_mod #t #l
unfold
let ( >>. ) #t #l = shift_right #t #l
unfold
let ( <<. ) #t #l = shift_left #t #l
unfold
let ( >>>. ) #t #l = rotate_right #t #l
unfold
let ( <<<. ) #t #l = rotate_left #t #l
unfold
let ( ^. ) #t #l = logxor #t #l
unfold
let ( |. ) #t #l = logor #t #l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Amp_Dot : _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | [] | Lib.IntTypes.op_Amp_Dot | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.int_t t l -> _: Lib.IntTypes.int_t t l -> Lib.IntTypes.int_t t l | {
"end_col": 31,
"end_line": 867,
"start_col": 19,
"start_line": 867
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modulus (t:inttype) = pow2 (bits t) | let modulus (t: inttype) = | false | null | false | pow2 (bits t) | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.pow2",
"Lib.IntTypes.bits",
"Prims.pos"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]] | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modulus : t: Lib.IntTypes.inttype -> Prims.pos | [] | Lib.IntTypes.modulus | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntTypes.inttype -> Prims.pos | {
"end_col": 39,
"end_line": 75,
"start_col": 26,
"start_line": 75
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1)) | let minint (t: inttype) = | false | null | false | if unsigned t then 0 else - (pow2 (bits t - 1)) | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.unsigned",
"Prims.bool",
"Prims.op_Minus",
"Prims.pow2",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"Prims.int"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val minint : t: Lib.IntTypes.inttype -> Prims.int | [] | Lib.IntTypes.minint | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntTypes.inttype -> Prims.int | {
"end_col": 48,
"end_line": 85,
"start_col": 2,
"start_line": 85
} |
|
Prims.Tot | val v (#t #l: _) (u: int_t t l) : range_t t | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u | val v (#t #l: _) (u: int_t t l) : range_t t
let v #t #l (u: int_t t l) : range_t t = | false | null | false | match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.int_t",
"Lib.IntTypes.pub_int_v",
"Lib.IntTypes.sec_int_v",
"Lib.IntTypes.range_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])] | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val v (#t #l: _) (u: int_t t l) : range_t t | [] | Lib.IntTypes.v | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | u38: Lib.IntTypes.int_t t l -> Lib.IntTypes.range_t t | {
"end_col": 25,
"end_line": 155,
"start_col": 2,
"start_line": 153
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16 | let numbytes = | false | null | false | function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16 | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.int"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val numbytes : _: Lib.IntTypes.inttype -> Prims.int | [] | Lib.IntTypes.numbytes | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.inttype -> Prims.int | {
"end_col": 14,
"end_line": 53,
"start_col": 15,
"start_line": 42
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t | let pub_int_t = | false | null | false | function
| U1 -> n: UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"FStar.UInt8.t",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt8.v",
"FStar.UInt16.t",
"FStar.UInt32.t",
"FStar.UInt64.t",
"FStar.UInt128.t",
"FStar.Int8.t",
"FStar.Int16.t",
"FStar.Int32.t",
"FStar.Int64.t",
"FStar.Int128.t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
/// | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pub_int_t : _: Lib.IntTypes.inttype -> Type0 | [] | Lib.IntTypes.pub_int_t | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntTypes.inttype -> Type0 | {
"end_col": 20,
"end_line": 109,
"start_col": 16,
"start_line": 98
} |
|
Prims.Tot | val size (n: size_nat) : size_t | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let size (n:size_nat) : size_t = uint #U32 #PUB n | val size (n: size_nat) : size_t
let size (n: size_nat) : size_t = | false | null | false | uint #U32 #PUB n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Lib.IntTypes.uint",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t} | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size (n: size_nat) : size_t | [] | Lib.IntTypes.size | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.size_nat -> Lib.IntTypes.size_t | {
"end_col": 49,
"end_line": 314,
"start_col": 33,
"start_line": 314
} |
Prims.Tot | val byte_v (s: byte_t) : n: size_nat{v s == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let byte_v (s:byte_t) : n:size_nat{v s == n} = v s | val byte_v (s: byte_t) : n: size_nat{v s == n}
let byte_v (s: byte_t) : n: size_nat{v s == n} = | false | null | false | v s | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.byte_t",
"Lib.IntTypes.v",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size_nat",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val byte_v (s: byte_t) : n: size_nat{v s == n} | [] | Lib.IntTypes.byte_v | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Lib.IntTypes.byte_t -> n: Lib.IntTypes.size_nat{Lib.IntTypes.v s == n} | {
"end_col": 50,
"end_line": 323,
"start_col": 47,
"start_line": 323
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1 | let ones_v (t: inttype) = | false | null | false | match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> - 1 | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.maxint",
"Prims.op_Minus",
"Prims.int"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction | false | true | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ones_v : t: Lib.IntTypes.inttype -> Prims.int | [] | Lib.IntTypes.ones_v | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntTypes.inttype -> Prims.int | {
"end_col": 37,
"end_line": 405,
"start_col": 2,
"start_line": 403
} |
|
Prims.Tot | val byte (n: nat{n < 256}) : b: byte_t{v b == n} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n | val byte (n: nat{n < 256}) : b: byte_t{v b == n}
let byte (n: nat{n < 256}) : b: byte_t{v b == n} = | false | null | false | uint #U8 #PUB n | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.uint",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Lib.IntTypes.byte_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val byte (n: nat{n < 256}) : b: byte_t{v b == n} | [] | Lib.IntTypes.byte | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Prims.nat{n < 256} -> b: Lib.IntTypes.byte_t{Lib.IntTypes.v b == n} | {
"end_col": 64,
"end_line": 320,
"start_col": 49,
"start_line": 320
} |
Prims.Tot | val logxor_v (#t: inttype) (a b: range_t t) : range_t t | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b | val logxor_v (#t: inttype) (a b: range_t t) : range_t t
let logxor_v (#t: inttype) (a b: range_t t) : range_t t = | false | null | false | match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.range_t",
"FStar.Int.logxor",
"Lib.IntTypes.bits",
"FStar.UInt.logxor"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1) | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val logxor_v (#t: inttype) (a b: range_t t) : range_t t | [] | Lib.IntTypes.logxor_v | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.IntTypes.range_t t -> b: Lib.IntTypes.range_t t -> Lib.IntTypes.range_t t | {
"end_col": 34,
"end_line": 547,
"start_col": 2,
"start_line": 545
} |
Prims.Tot | val shift_right_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s | val shift_right_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l
let shift_right_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l = | false | null | false | shift_right u s | {
"checked_file": "Lib.IntTypes.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.shiftval",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.shift_right"
] | [] | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l | false | false | Lib.IntTypes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val shift_right_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l | [] | Lib.IntTypes.shift_right_i | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Lib.IntTypes.shiftval t {Lib.IntTypes.unsigned t} -> u121: Lib.IntTypes.uint_t t l
-> Lib.IntTypes.uint_t t l | {
"end_col": 122,
"end_line": 708,
"start_col": 107,
"start_line": 708
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.