file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GC.fst | GC.alloc | val alloc: root:mem_addr -> abs:abs_node -> GCMut mem_addr
(requires (fun gc ->
try_alloc_invariant root abs gc gc
/\ abs <> no_abs
/\ (forall (i:mem_addr). trigger i /\ ptr_lifts gc i ==> gc.to_abs i <> abs)))
(ensures (fun gc ptr gc' -> (root <> 0 ==> ptr_lifts_to gc' root (gc.to_abs root))
/\ ptr_lifts gc' ptr
/\ gc'.abs_fields == gc.abs_fields)) | val alloc: root:mem_addr -> abs:abs_node -> GCMut mem_addr
(requires (fun gc ->
try_alloc_invariant root abs gc gc
/\ abs <> no_abs
/\ (forall (i:mem_addr). trigger i /\ ptr_lifts gc i ==> gc.to_abs i <> abs)))
(ensures (fun gc ptr gc' -> (root <> 0 ==> ptr_lifts_to gc' root (gc.to_abs root))
/\ ptr_lifts gc' ptr
/\ gc'.abs_fields == gc.abs_fields)) | let rec alloc root abs =
let rec try_alloc_at_ptr : ptr:mem_addr -> abs:abs_node -> GCMut int
(requires (fun gc ->
abs <> no_abs /\
trigger ptr /\
(forall (i:mem_addr). trigger i /\ ptr_lifts gc i ==> gc.to_abs i <> abs) /\
gc.abs_fields (abs, F1) = abs /\
gc.abs_fields (abs, F2) = abs))
(ensures (fun gc i gc' ->
gc'.abs_fields == gc.abs_fields
/\ (is_mem_addr i \/ i=mem_hi)
/\ (is_mem_addr i ==>
~(ptr_lifts gc i)
/\ ptr_lifts gc' i
/\ (forall (j:mem_addr). i <> j ==> gc'.to_abs j = gc.to_abs j))
/\ (i=mem_hi ==> gc==gc')))
= fun ptr abs ->
let gc = get () in
if gc.color ptr = Unalloc
then
begin let fields = upd_map #(mem_addr * field) #mem_addr gc.fields (ptr, F1) ptr in
let fields = upd_map #(mem_addr * field) #mem_addr fields (ptr, F2) ptr in
let gc' = { gc with
to_abs=upd_map gc.to_abs ptr abs;
color =upd_map gc.color ptr White;
fields=fields } in
set gc';
ptr
end
else if ptr + 1 < mem_hi
then try_alloc_at_ptr (ptr + 1) abs
else mem_hi in
let ptr = try_alloc_at_ptr mem_lo abs in
if ptr < mem_hi
then ptr
else (gc root; alloc root abs) | {
"file_name": "examples/algorithms/GC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 34,
"end_line": 301,
"start_col": 0,
"start_line": 266
} | (* Copyright Microsoft Research 2015
This module is an adaptation of Chris Hawblitzel and Erez Petrank's
simplified mark-sweep collector from the POPL 2009 paper
"Automated Verification of Practical Garbage Collectors"
While this module states and proves the same properties as the paper,
its implementation is currently still quite high-level, e.g, it
uses lots of recursive functions instead of while loops with mutable
local variables. Going lower level with this module is work in progress.
*)
module GC
type color =
| Unalloc
| White
| Gray
| Black
assume val mem_lo : x:int{0 < x}
assume val mem_hi : x:int{mem_lo < x}
let is_mem_addr i = mem_lo <= i && i < mem_hi
type field =
| F1
| F2
assume type abs_node : a:Type0{hasEq a}
assume val no_abs : abs_node
let valid a = a <> no_abs
type valid_node = a:abs_node{valid a}
type mem_addr = i:int{is_mem_addr i}
type color_map = mem_addr -> Tot color
type abs_map = mem_addr -> Tot abs_node
type field_map = mem_addr * field -> Tot mem_addr
type abs_field_map = abs_node * field -> Tot abs_node
type trigger (i:int) = True
type to_abs_inj (to_abs:abs_map) =
forall (i1:mem_addr) (i2:mem_addr).{:pattern (trigger i1); (trigger i2)}
trigger i1 /\
trigger i2 /\
valid (to_abs i1)
/\ valid (to_abs i2)
/\ i1 <> i2
==> to_abs i1 <> to_abs i2
noeq type gc_state = {
to_abs: abs_map;
color: color_map;
abs_fields: abs_field_map;
fields: field_map
}
type ptr_lifts gc_state (ptr:mem_addr) : Type =
b2t (valid (gc_state.to_abs ptr))
type ptr_lifts_to gc_state (ptr:mem_addr) (abs:abs_node) : Type =
valid abs
/\ gc_state.to_abs ptr = abs
type obj_inv gc_state (i:mem_addr) =
valid (gc_state.to_abs i)
==> (forall f. ptr_lifts_to gc_state (gc_state.fields (i, f)) (gc_state.abs_fields (gc_state.to_abs i, f)))
unfold type inv gc_state (color_invariant:mem_addr -> Type) =
to_abs_inj gc_state.to_abs
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i ==>
obj_inv gc_state i /\
color_invariant i /\
(not (valid (gc_state.to_abs i)) <==> gc_state.color i = Unalloc))
type gc_inv gc_state =
inv gc_state (fun i ->
(gc_state.color i = Black
==> (forall f. gc_state.color (gc_state.fields (i, f)) <> White)))
type mutator_inv gc_state =
inv gc_state (fun i -> gc_state.color i = Unalloc \/ gc_state.color i = White)
new_effect GC_STATE = STATE_h gc_state
let gc_post (a:Type) = a -> gc_state -> Type0
sub_effect
DIV ~> GC_STATE = fun (a:Type) (wp:pure_wp a) (p:gc_post a) (gc:gc_state) -> wp (fun a -> p a gc)
effect GC (a:Type) (pre:gc_state -> Type0) (post: gc_state -> Tot (gc_post a)) =
GC_STATE a
(fun (p:gc_post a) (gc:gc_state) ->
pre gc /\ (forall a gc'. (pre gc /\ post gc a gc') ==> p a gc')) (* WP *)
effect GCMut (res:Type) (req:gc_state -> Type0) (ens:gc_state -> Tot (gc_post res)) =
GC res (fun gc -> req gc /\ mutator_inv gc)
(fun gc res gc' -> ens gc res gc' /\ mutator_inv gc')
assume val get : unit -> GC gc_state (fun gc -> True) (fun gc res gc' -> gc==gc' /\ res==gc')
assume val set : g:gc_state -> GC unit (fun gc -> True) (fun _ _ gc' -> g==gc')
type init_invariant (ptr:mem_addr) (gc:gc_state) =
forall i. mem_lo <= i /\ i < ptr
==> not(valid (gc.to_abs i))
/\ gc.color i = Unalloc
val upd_map: #a:eqtype -> #b:Type -> (a -> Tot b) -> a -> b -> a -> Tot b
let upd_map #a #b f i v = fun j -> if i=j then v else f j
val upd_map2: #a:eqtype -> #b:eqtype -> #c:Type -> (a -> b -> Tot c) -> a -> b -> c -> a -> b -> Tot c
let upd_map2 #a #b #c m i f v = fun j g -> if (i,f)=(j,g) then v else m j g
val initialize: unit -> GC unit
(requires (fun g -> True))
(ensures (fun g _ g' -> mutator_inv g'))
let initialize () =
let rec aux_init : ptr:mem_addr -> GC unit
(requires (init_invariant ptr))
(ensures (fun gc _ gc' -> mutator_inv gc'))
= fun ptr ->
let gc = get () in
let gc' = {gc with
color=upd_map gc.color ptr Unalloc;
to_abs=upd_map gc.to_abs ptr no_abs
} in
set gc';
if ptr + 1 < mem_hi then aux_init (ptr + 1) in
aux_init mem_lo
val read_field : ptr:mem_addr -> f:field -> GCMut mem_addr
(requires (fun gc -> ptr_lifts_to gc ptr (gc.to_abs ptr)))
(ensures (fun gc i gc' -> gc==gc'
/\ ptr_lifts_to gc' i (gc.abs_fields (gc.to_abs ptr, f))))
let read_field ptr f =
cut (trigger ptr);
let gc = get () in
gc.fields (ptr, f)
val write_field: ptr:mem_addr -> f:field -> v:mem_addr -> GCMut unit
(requires (fun gc -> ptr_lifts gc ptr /\ ptr_lifts gc v))
(ensures (fun gc _ gc' -> gc'.color==gc.color))
let write_field ptr f v =
cut (trigger ptr /\ trigger v);
let gc = get () in
let gc' = {gc with
fields=upd_map gc.fields (ptr, f) v;
abs_fields=upd_map gc.abs_fields (gc.to_abs ptr, f) (gc.to_abs v);
} in
set gc'
val mark : ptr:mem_addr -> GC unit
(requires (fun gc -> gc_inv gc /\ trigger ptr /\ ptr_lifts gc ptr))
(ensures (fun gc _ gc' -> gc_inv gc'
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i ==>
(gc'.color i <> Black
==> gc.color i = gc'.color i))
/\ gc'.color ptr <> White
/\ (exists c. gc' == {gc with color=c})))
let rec mark ptr =
let st = get () in
if st.color ptr = White
then begin
let st' = {st with color=upd_map st.color ptr Gray} in
set st';
mark (st'.fields (ptr, F1));
mark (st'.fields (ptr, F2));
let st'' = get () in
set ({st'' with color = upd_map st''.color ptr Black})
end
type sweep_aux_inv (old:gc_state) (ptr:int) (st:gc_state) =
gc_inv old
/\ (st.fields == old.fields /\ st.abs_fields == old.abs_fields)
/\ to_abs_inj st.to_abs
/\ (forall (i:mem_addr). {:pattern (trigger i)}
trigger i
==> st.color i <> Gray
/\ (old.color i = Black
==> (ptr_lifts st i
/\ obj_inv st i
/\ (forall f. st.fields (i, f) >= ptr ==> st.color (st.fields (i, f)) <> White)))
/\ (~(ptr_lifts st i) <==> st.color i=Unalloc)
/\ (ptr_lifts st i ==> old.to_abs i = st.to_abs i)
/\ (ptr <= i ==> old.color i = st.color i)
/\ (i < ptr ==> (st.color i = Unalloc \/ st.color i = White))
/\ (i < ptr /\ st.color i = White ==> old.color i = Black)
)
let test1 old n = assert (sweep_aux_inv old mem_hi n
==> mutator_inv n)
let test2 old = assert (gc_inv old /\ (forall i. old.color i <> Gray) ==> sweep_aux_inv old mem_lo old)
val sweep: unit -> GC unit
(requires (fun gc -> gc_inv gc
/\ (forall (i:mem_addr). {:pattern (trigger i)}
trigger i
==> gc.color i <> Gray)))
(ensures (fun gc _ gc' -> (exists c a. gc' == {gc with color=c; to_abs=a}
/\ mutator_inv gc'
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i
==> (gc.color i=Black ==> ptr_lifts gc' i)
/\ (ptr_lifts gc' i ==> gc.to_abs i = gc'.to_abs i)))))
let sweep () =
let old = get () in
let rec sweep_aux : ptr:mem_addr -> GC unit
(requires (fun gc -> sweep_aux_inv old ptr gc))
(ensures (fun _ _ st ->
(st.abs_fields == old.abs_fields
/\ st.fields == old.fields
/\ mutator_inv st
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i
==> (old.color i=Black ==> ptr_lifts st i)
/\ (ptr_lifts st i ==> old.to_abs i = st.to_abs i)))))
= fun ptr ->
cut (trigger ptr);
let st = get () in
if st.color ptr = White //deallocate
then (let st' = {st with
color=upd_map st.color ptr Unalloc;
to_abs=upd_map st.to_abs ptr no_abs} in
set st')
else if st.color ptr = Black
then
begin let st' = {st with color=upd_map st.color ptr White} in
set st'
end;
if ptr + 1 < mem_hi
then sweep_aux (ptr + 1) in
sweep_aux mem_lo
val gc: root:mem_addr -> GCMut unit
(requires (fun gc -> root<>0 ==> ptr_lifts gc root))
(ensures (fun gc _ gc' -> (exists c a. gc' == {gc with color=c; to_abs=a})
/\ (root<>0 ==> ptr_lifts gc' root)
/\ (forall (i:mem_addr). {:pattern (trigger i)}
trigger i ==> (ptr_lifts gc' i ==> gc.to_abs i = gc'.to_abs i))
/\ (root <> 0 ==> gc.to_abs root = gc'.to_abs root)))
let gc root =
cut (trigger root);
if (root <> 0)
then mark root;
sweep ()
type try_alloc_invariant (root:mem_addr) (abs:abs_node) (gc:gc_state) (gc':gc_state) =
(root <> 0 ==> ptr_lifts_to gc' root (gc.to_abs root))
/\ gc'.abs_fields (abs, F1) = abs
/\ gc'.abs_fields (abs, F2) = abs
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i
==> (ptr_lifts gc i
==> gc'.to_abs i <> abs))
val alloc: root:mem_addr -> abs:abs_node -> GCMut mem_addr
(requires (fun gc ->
try_alloc_invariant root abs gc gc
/\ abs <> no_abs
/\ (forall (i:mem_addr). trigger i /\ ptr_lifts gc i ==> gc.to_abs i <> abs)))
(ensures (fun gc ptr gc' -> (root <> 0 ==> ptr_lifts_to gc' root (gc.to_abs root))
/\ ptr_lifts gc' ptr | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "GC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | root: GC.mem_addr -> abs: GC.abs_node -> GC.GCMut GC.mem_addr | GC.GCMut | [] | [] | [
"GC.mem_addr",
"GC.abs_node",
"Prims.op_LessThan",
"GC.mem_hi",
"Prims.bool",
"GC.alloc",
"Prims.unit",
"GC.gc",
"Prims.int",
"GC.mem_lo",
"GC.gc_state",
"Prims.l_and",
"Prims.b2t",
"Prims.op_disEquality",
"GC.no_abs",
"GC.trigger",
"Prims.l_Forall",
"Prims.l_imp",
"GC.ptr_lifts",
"GC.__proj__Mkgc_state__item__to_abs",
"Prims.op_Equality",
"GC.__proj__Mkgc_state__item__abs_fields",
"FStar.Pervasives.Native.Mktuple2",
"GC.field",
"GC.F1",
"GC.F2",
"Prims.eq2",
"GC.abs_field_map",
"Prims.l_or",
"GC.is_mem_addr",
"Prims.l_not",
"GC.color",
"GC.__proj__Mkgc_state__item__color",
"GC.Unalloc",
"GC.set",
"GC.Mkgc_state",
"GC.upd_map",
"GC.White",
"FStar.Pervasives.Native.tuple2",
"GC.__proj__Mkgc_state__item__fields",
"Prims.op_Addition",
"GC.get"
] | [
"recursion"
] | false | true | false | false | false | let rec alloc root abs =
| let rec try_alloc_at_ptr: ptr: mem_addr -> abs: abs_node
-> GCMut int
(requires
(fun gc ->
abs <> no_abs /\ trigger ptr /\
(forall (i: mem_addr). trigger i /\ ptr_lifts gc i ==> gc.to_abs i <> abs) /\
gc.abs_fields (abs, F1) = abs /\ gc.abs_fields (abs, F2) = abs))
(ensures
(fun gc i gc' ->
gc'.abs_fields == gc.abs_fields /\ (is_mem_addr i \/ i = mem_hi) /\
(is_mem_addr i ==>
~(ptr_lifts gc i) /\ ptr_lifts gc' i /\
(forall (j: mem_addr). i <> j ==> gc'.to_abs j = gc.to_abs j)) /\
(i = mem_hi ==> gc == gc'))) =
fun ptr abs ->
let gc = get () in
if gc.color ptr = Unalloc
then
let fields = upd_map #(mem_addr * field) #mem_addr gc.fields (ptr, F1) ptr in
let fields = upd_map #(mem_addr * field) #mem_addr fields (ptr, F2) ptr in
let gc' =
{
gc with
to_abs = upd_map gc.to_abs ptr abs;
color = upd_map gc.color ptr White;
fields = fields
}
in
set gc';
ptr
else if ptr + 1 < mem_hi then try_alloc_at_ptr (ptr + 1) abs else mem_hi
in
let ptr = try_alloc_at_ptr mem_lo abs in
if ptr < mem_hi
then ptr
else
(gc root;
alloc root abs) | false |
FStar.Reflection.V2.Formula.fst | FStar.Reflection.V2.Formula.term_as_formula | val term_as_formula (t: term) : Tac formula | val term_as_formula (t: term) : Tac formula | let term_as_formula (t:term) : Tac formula =
match unsquash_term t with
| None -> F_Unknown
| Some t ->
term_as_formula' t | {
"file_name": "ulib/FStar.Reflection.V2.Formula.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 170,
"start_col": 0,
"start_line": 166
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.V2.Formula
open FStar.List.Tot.Base
open FStar.Stubs.Reflection.Types
open FStar.Reflection.Const
open FStar.Stubs.Reflection.V2.Builtins
open FStar.Reflection.V2.Derived
open FStar.Stubs.Reflection.V2.Data
open FStar.Stubs.Tactics.Common
open FStar.Tactics.Effect
open FStar.Stubs.Tactics.V2.Builtins
open FStar.Tactics.NamedView
///// Helpers (we cannot use the ones in Tactics.V2.Derived, those are for named views /////
private let rec inspect_unascribe (t:term) : Tac term_view =
match inspect t with
| Tv_AscribedT t _ _ _
| Tv_AscribedC t _ _ _ ->
inspect_unascribe t
| tv -> tv
private let rec collect_app' (args : list argv) (t : term)
: Tac (term * list argv) (decreases t) =
match inspect_unascribe t with
| Tv_App l r ->
collect_app' (r::args) l
| _ -> (t, args)
private let collect_app = collect_app' []
/////
[@@plugin]
noeq type comparison =
| Eq of option typ (* Propositional equality (eq2), maybe annotated *)
| BoolEq of option typ (* Decidable, boolean equality (eq), maybe annotated *)
| Lt | Le | Gt | Ge (* Orderings, at type `int` (and subtypes) *)
[@@plugin]
noeq type formula =
| True_ : formula
| False_ : formula
| Comp : comparison -> term -> term -> formula
| And : term -> term -> formula
| Or : term -> term -> formula
| Not : term -> formula
| Implies: term -> term -> formula
| Iff : term -> term -> formula
| Forall : bv -> typ -> term -> formula
| Exists : bv -> typ -> term -> formula
| App : term -> term -> formula
| Name : namedv -> formula
| FV : fv -> formula
| IntLit : int -> formula
| F_Unknown : formula // Also a baked-in "None"
let mk_Forall (typ : term) (pred : term) : Tot formula =
let b = pack_bv ({ ppname = as_ppname "x";
sort = seal typ;
index = 0; }) in
Forall b typ (pack (Tv_App pred (pack (Tv_BVar b), Q_Explicit)))
let mk_Exists (typ : term) (pred : term) : Tot formula =
let b = pack_bv ({ ppname = as_ppname "x";
sort = seal typ;
index = 0; }) in
Exists b typ (pack (Tv_App pred (pack (Tv_BVar b), Q_Explicit)))
[@@plugin]
let term_as_formula' (t:term) : Tac formula =
match inspect_unascribe t with
| Tv_Var n ->
Name n
| Tv_FVar fv
| Tv_UInst fv _ ->
// Cannot use `when` clauses when verifying!
let qn = inspect_fv fv in
if qn = true_qn then True_
else if qn = false_qn then False_
else FV fv
// TODO: l_Forall
// ...or should we just try to drop all squashes?
// TODO: b2t at this point ?
| Tv_App h0 t -> begin
let (h, ts) = collect_app h0 in
let h = un_uinst h in
match inspect h, ts@[t] with
| Tv_FVar fv, [(a1, Q_Implicit); (a2, Q_Explicit); (a3, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = eq2_qn then Comp (Eq (Some a1)) a2 a3
else if qn = eq1_qn then Comp (BoolEq (Some a1)) a2 a3
else if qn = lt_qn then Comp Lt a2 a3
else if qn = lte_qn then Comp Le a2 a3
else if qn = gt_qn then Comp Gt a2 a3
else if qn = gte_qn then Comp Ge a2 a3
else App h0 (fst t)
| Tv_FVar fv, [(a1, Q_Explicit); (a2, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = imp_qn then Implies a1 a2
else if qn = and_qn then And a1 a2
else if qn = iff_qn then Iff a1 a2
else if qn = or_qn then Or a1 a2
// Non-annotated comparisons
else if qn = eq2_qn then Comp (Eq None) a1 a2
else if qn = eq1_qn then Comp (BoolEq None) a1 a2
else App h0 (fst t)
| Tv_FVar fv, [(a1, Q_Implicit); (a2, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = forall_qn then mk_Forall a1 a2
else if qn = exists_qn then mk_Exists a1 a2
else App h0 (fst t)
| Tv_FVar fv, [(a, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = not_qn then Not a
else if qn = b2t_qn then begin
if term_eq a (`false) then False_
else if term_eq a (`true) then True_
else App h0 (fst t)
end
else App h0 (fst t)
| _ ->
App h0 (fst t)
end
| Tv_Const (C_Int i) ->
IntLit i
(* Not formulas. *)
| Tv_Let _ _ _ _ _
| Tv_Match _ _ _
| Tv_Type _
| Tv_Abs _ _
| Tv_Arrow _ _
| Tv_Uvar _ _
| Tv_Unknown
| Tv_Unsupp
| Tv_Refine _ _ -> F_Unknown
(* Other constants? *)
| Tv_Const _ -> F_Unknown
(* Should not occur, we're using inspect *)
| Tv_BVar _ -> F_Unknown
| _ -> raise (TacticFailure "???") | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.NamedView.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Tactics.Common.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Stubs.Reflection.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.Types.fsti.checked",
"FStar.Reflection.V2.Derived.fst.checked",
"FStar.Reflection.Const.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.V2.Formula.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.NamedView",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.Common",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac FStar.Reflection.V2.Formula.formula | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Tactics.NamedView.term",
"FStar.Reflection.V2.Derived.unsquash_term",
"FStar.Reflection.V2.Formula.F_Unknown",
"FStar.Reflection.V2.Formula.formula",
"FStar.Stubs.Reflection.Types.term",
"FStar.Reflection.V2.Formula.term_as_formula'"
] | [] | false | true | false | false | false | let term_as_formula (t: term) : Tac formula =
| match unsquash_term t with
| None -> F_Unknown
| Some t -> term_as_formula' t | false |
GC.fst | GC.sweep | val sweep: unit -> GC unit
(requires (fun gc -> gc_inv gc
/\ (forall (i:mem_addr). {:pattern (trigger i)}
trigger i
==> gc.color i <> Gray)))
(ensures (fun gc _ gc' -> (exists c a. gc' == {gc with color=c; to_abs=a}
/\ mutator_inv gc'
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i
==> (gc.color i=Black ==> ptr_lifts gc' i)
/\ (ptr_lifts gc' i ==> gc.to_abs i = gc'.to_abs i))))) | val sweep: unit -> GC unit
(requires (fun gc -> gc_inv gc
/\ (forall (i:mem_addr). {:pattern (trigger i)}
trigger i
==> gc.color i <> Gray)))
(ensures (fun gc _ gc' -> (exists c a. gc' == {gc with color=c; to_abs=a}
/\ mutator_inv gc'
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i
==> (gc.color i=Black ==> ptr_lifts gc' i)
/\ (ptr_lifts gc' i ==> gc.to_abs i = gc'.to_abs i))))) | let sweep () =
let old = get () in
let rec sweep_aux : ptr:mem_addr -> GC unit
(requires (fun gc -> sweep_aux_inv old ptr gc))
(ensures (fun _ _ st ->
(st.abs_fields == old.abs_fields
/\ st.fields == old.fields
/\ mutator_inv st
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i
==> (old.color i=Black ==> ptr_lifts st i)
/\ (ptr_lifts st i ==> old.to_abs i = st.to_abs i)))))
= fun ptr ->
cut (trigger ptr);
let st = get () in
if st.color ptr = White //deallocate
then (let st' = {st with
color=upd_map st.color ptr Unalloc;
to_abs=upd_map st.to_abs ptr no_abs} in
set st')
else if st.color ptr = Black
then
begin let st' = {st with color=upd_map st.color ptr White} in
set st'
end;
if ptr + 1 < mem_hi
then sweep_aux (ptr + 1) in
sweep_aux mem_lo | {
"file_name": "examples/algorithms/GC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 234,
"start_col": 0,
"start_line": 207
} | (* Copyright Microsoft Research 2015
This module is an adaptation of Chris Hawblitzel and Erez Petrank's
simplified mark-sweep collector from the POPL 2009 paper
"Automated Verification of Practical Garbage Collectors"
While this module states and proves the same properties as the paper,
its implementation is currently still quite high-level, e.g, it
uses lots of recursive functions instead of while loops with mutable
local variables. Going lower level with this module is work in progress.
*)
module GC
type color =
| Unalloc
| White
| Gray
| Black
assume val mem_lo : x:int{0 < x}
assume val mem_hi : x:int{mem_lo < x}
let is_mem_addr i = mem_lo <= i && i < mem_hi
type field =
| F1
| F2
assume type abs_node : a:Type0{hasEq a}
assume val no_abs : abs_node
let valid a = a <> no_abs
type valid_node = a:abs_node{valid a}
type mem_addr = i:int{is_mem_addr i}
type color_map = mem_addr -> Tot color
type abs_map = mem_addr -> Tot abs_node
type field_map = mem_addr * field -> Tot mem_addr
type abs_field_map = abs_node * field -> Tot abs_node
type trigger (i:int) = True
type to_abs_inj (to_abs:abs_map) =
forall (i1:mem_addr) (i2:mem_addr).{:pattern (trigger i1); (trigger i2)}
trigger i1 /\
trigger i2 /\
valid (to_abs i1)
/\ valid (to_abs i2)
/\ i1 <> i2
==> to_abs i1 <> to_abs i2
noeq type gc_state = {
to_abs: abs_map;
color: color_map;
abs_fields: abs_field_map;
fields: field_map
}
type ptr_lifts gc_state (ptr:mem_addr) : Type =
b2t (valid (gc_state.to_abs ptr))
type ptr_lifts_to gc_state (ptr:mem_addr) (abs:abs_node) : Type =
valid abs
/\ gc_state.to_abs ptr = abs
type obj_inv gc_state (i:mem_addr) =
valid (gc_state.to_abs i)
==> (forall f. ptr_lifts_to gc_state (gc_state.fields (i, f)) (gc_state.abs_fields (gc_state.to_abs i, f)))
unfold type inv gc_state (color_invariant:mem_addr -> Type) =
to_abs_inj gc_state.to_abs
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i ==>
obj_inv gc_state i /\
color_invariant i /\
(not (valid (gc_state.to_abs i)) <==> gc_state.color i = Unalloc))
type gc_inv gc_state =
inv gc_state (fun i ->
(gc_state.color i = Black
==> (forall f. gc_state.color (gc_state.fields (i, f)) <> White)))
type mutator_inv gc_state =
inv gc_state (fun i -> gc_state.color i = Unalloc \/ gc_state.color i = White)
new_effect GC_STATE = STATE_h gc_state
let gc_post (a:Type) = a -> gc_state -> Type0
sub_effect
DIV ~> GC_STATE = fun (a:Type) (wp:pure_wp a) (p:gc_post a) (gc:gc_state) -> wp (fun a -> p a gc)
effect GC (a:Type) (pre:gc_state -> Type0) (post: gc_state -> Tot (gc_post a)) =
GC_STATE a
(fun (p:gc_post a) (gc:gc_state) ->
pre gc /\ (forall a gc'. (pre gc /\ post gc a gc') ==> p a gc')) (* WP *)
effect GCMut (res:Type) (req:gc_state -> Type0) (ens:gc_state -> Tot (gc_post res)) =
GC res (fun gc -> req gc /\ mutator_inv gc)
(fun gc res gc' -> ens gc res gc' /\ mutator_inv gc')
assume val get : unit -> GC gc_state (fun gc -> True) (fun gc res gc' -> gc==gc' /\ res==gc')
assume val set : g:gc_state -> GC unit (fun gc -> True) (fun _ _ gc' -> g==gc')
type init_invariant (ptr:mem_addr) (gc:gc_state) =
forall i. mem_lo <= i /\ i < ptr
==> not(valid (gc.to_abs i))
/\ gc.color i = Unalloc
val upd_map: #a:eqtype -> #b:Type -> (a -> Tot b) -> a -> b -> a -> Tot b
let upd_map #a #b f i v = fun j -> if i=j then v else f j
val upd_map2: #a:eqtype -> #b:eqtype -> #c:Type -> (a -> b -> Tot c) -> a -> b -> c -> a -> b -> Tot c
let upd_map2 #a #b #c m i f v = fun j g -> if (i,f)=(j,g) then v else m j g
val initialize: unit -> GC unit
(requires (fun g -> True))
(ensures (fun g _ g' -> mutator_inv g'))
let initialize () =
let rec aux_init : ptr:mem_addr -> GC unit
(requires (init_invariant ptr))
(ensures (fun gc _ gc' -> mutator_inv gc'))
= fun ptr ->
let gc = get () in
let gc' = {gc with
color=upd_map gc.color ptr Unalloc;
to_abs=upd_map gc.to_abs ptr no_abs
} in
set gc';
if ptr + 1 < mem_hi then aux_init (ptr + 1) in
aux_init mem_lo
val read_field : ptr:mem_addr -> f:field -> GCMut mem_addr
(requires (fun gc -> ptr_lifts_to gc ptr (gc.to_abs ptr)))
(ensures (fun gc i gc' -> gc==gc'
/\ ptr_lifts_to gc' i (gc.abs_fields (gc.to_abs ptr, f))))
let read_field ptr f =
cut (trigger ptr);
let gc = get () in
gc.fields (ptr, f)
val write_field: ptr:mem_addr -> f:field -> v:mem_addr -> GCMut unit
(requires (fun gc -> ptr_lifts gc ptr /\ ptr_lifts gc v))
(ensures (fun gc _ gc' -> gc'.color==gc.color))
let write_field ptr f v =
cut (trigger ptr /\ trigger v);
let gc = get () in
let gc' = {gc with
fields=upd_map gc.fields (ptr, f) v;
abs_fields=upd_map gc.abs_fields (gc.to_abs ptr, f) (gc.to_abs v);
} in
set gc'
val mark : ptr:mem_addr -> GC unit
(requires (fun gc -> gc_inv gc /\ trigger ptr /\ ptr_lifts gc ptr))
(ensures (fun gc _ gc' -> gc_inv gc'
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i ==>
(gc'.color i <> Black
==> gc.color i = gc'.color i))
/\ gc'.color ptr <> White
/\ (exists c. gc' == {gc with color=c})))
let rec mark ptr =
let st = get () in
if st.color ptr = White
then begin
let st' = {st with color=upd_map st.color ptr Gray} in
set st';
mark (st'.fields (ptr, F1));
mark (st'.fields (ptr, F2));
let st'' = get () in
set ({st'' with color = upd_map st''.color ptr Black})
end
type sweep_aux_inv (old:gc_state) (ptr:int) (st:gc_state) =
gc_inv old
/\ (st.fields == old.fields /\ st.abs_fields == old.abs_fields)
/\ to_abs_inj st.to_abs
/\ (forall (i:mem_addr). {:pattern (trigger i)}
trigger i
==> st.color i <> Gray
/\ (old.color i = Black
==> (ptr_lifts st i
/\ obj_inv st i
/\ (forall f. st.fields (i, f) >= ptr ==> st.color (st.fields (i, f)) <> White)))
/\ (~(ptr_lifts st i) <==> st.color i=Unalloc)
/\ (ptr_lifts st i ==> old.to_abs i = st.to_abs i)
/\ (ptr <= i ==> old.color i = st.color i)
/\ (i < ptr ==> (st.color i = Unalloc \/ st.color i = White))
/\ (i < ptr /\ st.color i = White ==> old.color i = Black)
)
let test1 old n = assert (sweep_aux_inv old mem_hi n
==> mutator_inv n)
let test2 old = assert (gc_inv old /\ (forall i. old.color i <> Gray) ==> sweep_aux_inv old mem_lo old)
val sweep: unit -> GC unit
(requires (fun gc -> gc_inv gc
/\ (forall (i:mem_addr). {:pattern (trigger i)}
trigger i
==> gc.color i <> Gray)))
(ensures (fun gc _ gc' -> (exists c a. gc' == {gc with color=c; to_abs=a}
/\ mutator_inv gc'
/\ (forall (i:mem_addr).{:pattern (trigger i)}
trigger i
==> (gc.color i=Black ==> ptr_lifts gc' i) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "GC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> GC.GC Prims.unit | GC.GC | [] | [] | [
"Prims.unit",
"GC.mem_lo",
"GC.mem_addr",
"GC.gc_state",
"GC.sweep_aux_inv",
"Prims.l_and",
"Prims.eq2",
"GC.abs_field_map",
"GC.__proj__Mkgc_state__item__abs_fields",
"GC.field_map",
"GC.__proj__Mkgc_state__item__fields",
"GC.mutator_inv",
"Prims.l_Forall",
"Prims.l_imp",
"GC.trigger",
"Prims.b2t",
"Prims.op_Equality",
"GC.color",
"GC.__proj__Mkgc_state__item__color",
"GC.Black",
"GC.ptr_lifts",
"GC.abs_node",
"GC.__proj__Mkgc_state__item__to_abs",
"Prims.op_LessThan",
"Prims.op_Addition",
"GC.mem_hi",
"Prims.bool",
"GC.White",
"GC.set",
"GC.Mkgc_state",
"GC.upd_map",
"GC.no_abs",
"GC.Unalloc",
"GC.get",
"Prims.cut"
] | [] | false | true | false | false | false | let sweep () =
| let old = get () in
let rec sweep_aux: ptr: mem_addr
-> GC unit
(requires (fun gc -> sweep_aux_inv old ptr gc))
(ensures
(fun _ _ st ->
(st.abs_fields == old.abs_fields /\ st.fields == old.fields /\ mutator_inv st /\
(forall (i: mem_addr). {:pattern (trigger i)}
trigger i ==>
(old.color i = Black ==> ptr_lifts st i) /\
(ptr_lifts st i ==> old.to_abs i = st.to_abs i))))) =
fun ptr ->
cut (trigger ptr);
let st = get () in
if st.color ptr = White
then
(let st' =
{ st with color = upd_map st.color ptr Unalloc; to_abs = upd_map st.to_abs ptr no_abs }
in
set st')
else
if st.color ptr = Black
then
(let st' = { st with color = upd_map st.color ptr White } in
set st');
if ptr + 1 < mem_hi then sweep_aux (ptr + 1)
in
sweep_aux mem_lo | false |
FStar.Reflection.V2.Formula.fst | FStar.Reflection.V2.Formula.formula_as_term_view | val formula_as_term_view (f: formula) : Tot term_view | val formula_as_term_view (f: formula) : Tot term_view | let formula_as_term_view (f:formula) : Tot term_view =
let mk_app' tv args = List.Tot.Base.fold_left (fun tv a -> Tv_App (pack tv) a) tv args in
let e = Q_Explicit in
let i = Q_Implicit in
match f with
| True_ -> Tv_FVar (pack_fv true_qn)
| False_ -> Tv_FVar (pack_fv false_qn)
| Comp (Eq None) l r -> mk_app' (Tv_FVar (pack_fv eq2_qn)) [(l,e);(r,e)]
| Comp (Eq (Some t)) l r -> mk_app' (Tv_FVar (pack_fv eq2_qn)) [(t,i);(l,e);(r,e)]
| Comp (BoolEq None) l r -> mk_app' (Tv_FVar (pack_fv eq1_qn)) [(l,e);(r,e)]
| Comp (BoolEq (Some t)) l r -> mk_app' (Tv_FVar (pack_fv eq1_qn)) [(t,i);(l,e);(r,e)]
| Comp Lt l r -> mk_app' (Tv_FVar (pack_fv lt_qn)) [(l,e);(r,e)]
| Comp Le l r -> mk_app' (Tv_FVar (pack_fv lte_qn)) [(l,e);(r,e)]
| Comp Gt l r -> mk_app' (Tv_FVar (pack_fv gt_qn)) [(l,e);(r,e)]
| Comp Ge l r -> mk_app' (Tv_FVar (pack_fv gte_qn)) [(l,e);(r,e)]
| And p q -> mk_app' (Tv_FVar (pack_fv and_qn)) [(p,e);(q,e)]
| Or p q -> mk_app' (Tv_FVar (pack_fv or_qn)) [(p,e);(q,e)]
| Implies p q -> mk_app' (Tv_FVar (pack_fv imp_qn)) [(p,e);(q,e)]
| Not p -> mk_app' (Tv_FVar (pack_fv not_qn)) [(p,e)]
| Iff p q -> mk_app' (Tv_FVar (pack_fv iff_qn)) [(p,e);(q,e)]
| Forall b sort t -> Tv_Unknown // TODO: decide on meaning of this
| Exists b sort t -> Tv_Unknown // TODO: ^
| App p q ->
Tv_App p (q, Q_Explicit)
| Name b ->
Tv_Var b
| FV fv ->
Tv_FVar fv
| IntLit i ->
Tv_Const (C_Int i)
| F_Unknown ->
Tv_Unknown | {
"file_name": "ulib/FStar.Reflection.V2.Formula.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 213,
"start_col": 0,
"start_line": 177
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.V2.Formula
open FStar.List.Tot.Base
open FStar.Stubs.Reflection.Types
open FStar.Reflection.Const
open FStar.Stubs.Reflection.V2.Builtins
open FStar.Reflection.V2.Derived
open FStar.Stubs.Reflection.V2.Data
open FStar.Stubs.Tactics.Common
open FStar.Tactics.Effect
open FStar.Stubs.Tactics.V2.Builtins
open FStar.Tactics.NamedView
///// Helpers (we cannot use the ones in Tactics.V2.Derived, those are for named views /////
private let rec inspect_unascribe (t:term) : Tac term_view =
match inspect t with
| Tv_AscribedT t _ _ _
| Tv_AscribedC t _ _ _ ->
inspect_unascribe t
| tv -> tv
private let rec collect_app' (args : list argv) (t : term)
: Tac (term * list argv) (decreases t) =
match inspect_unascribe t with
| Tv_App l r ->
collect_app' (r::args) l
| _ -> (t, args)
private let collect_app = collect_app' []
/////
[@@plugin]
noeq type comparison =
| Eq of option typ (* Propositional equality (eq2), maybe annotated *)
| BoolEq of option typ (* Decidable, boolean equality (eq), maybe annotated *)
| Lt | Le | Gt | Ge (* Orderings, at type `int` (and subtypes) *)
[@@plugin]
noeq type formula =
| True_ : formula
| False_ : formula
| Comp : comparison -> term -> term -> formula
| And : term -> term -> formula
| Or : term -> term -> formula
| Not : term -> formula
| Implies: term -> term -> formula
| Iff : term -> term -> formula
| Forall : bv -> typ -> term -> formula
| Exists : bv -> typ -> term -> formula
| App : term -> term -> formula
| Name : namedv -> formula
| FV : fv -> formula
| IntLit : int -> formula
| F_Unknown : formula // Also a baked-in "None"
let mk_Forall (typ : term) (pred : term) : Tot formula =
let b = pack_bv ({ ppname = as_ppname "x";
sort = seal typ;
index = 0; }) in
Forall b typ (pack (Tv_App pred (pack (Tv_BVar b), Q_Explicit)))
let mk_Exists (typ : term) (pred : term) : Tot formula =
let b = pack_bv ({ ppname = as_ppname "x";
sort = seal typ;
index = 0; }) in
Exists b typ (pack (Tv_App pred (pack (Tv_BVar b), Q_Explicit)))
[@@plugin]
let term_as_formula' (t:term) : Tac formula =
match inspect_unascribe t with
| Tv_Var n ->
Name n
| Tv_FVar fv
| Tv_UInst fv _ ->
// Cannot use `when` clauses when verifying!
let qn = inspect_fv fv in
if qn = true_qn then True_
else if qn = false_qn then False_
else FV fv
// TODO: l_Forall
// ...or should we just try to drop all squashes?
// TODO: b2t at this point ?
| Tv_App h0 t -> begin
let (h, ts) = collect_app h0 in
let h = un_uinst h in
match inspect h, ts@[t] with
| Tv_FVar fv, [(a1, Q_Implicit); (a2, Q_Explicit); (a3, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = eq2_qn then Comp (Eq (Some a1)) a2 a3
else if qn = eq1_qn then Comp (BoolEq (Some a1)) a2 a3
else if qn = lt_qn then Comp Lt a2 a3
else if qn = lte_qn then Comp Le a2 a3
else if qn = gt_qn then Comp Gt a2 a3
else if qn = gte_qn then Comp Ge a2 a3
else App h0 (fst t)
| Tv_FVar fv, [(a1, Q_Explicit); (a2, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = imp_qn then Implies a1 a2
else if qn = and_qn then And a1 a2
else if qn = iff_qn then Iff a1 a2
else if qn = or_qn then Or a1 a2
// Non-annotated comparisons
else if qn = eq2_qn then Comp (Eq None) a1 a2
else if qn = eq1_qn then Comp (BoolEq None) a1 a2
else App h0 (fst t)
| Tv_FVar fv, [(a1, Q_Implicit); (a2, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = forall_qn then mk_Forall a1 a2
else if qn = exists_qn then mk_Exists a1 a2
else App h0 (fst t)
| Tv_FVar fv, [(a, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = not_qn then Not a
else if qn = b2t_qn then begin
if term_eq a (`false) then False_
else if term_eq a (`true) then True_
else App h0 (fst t)
end
else App h0 (fst t)
| _ ->
App h0 (fst t)
end
| Tv_Const (C_Int i) ->
IntLit i
(* Not formulas. *)
| Tv_Let _ _ _ _ _
| Tv_Match _ _ _
| Tv_Type _
| Tv_Abs _ _
| Tv_Arrow _ _
| Tv_Uvar _ _
| Tv_Unknown
| Tv_Unsupp
| Tv_Refine _ _ -> F_Unknown
(* Other constants? *)
| Tv_Const _ -> F_Unknown
(* Should not occur, we're using inspect *)
| Tv_BVar _ -> F_Unknown
| _ -> raise (TacticFailure "???")
// Unsquashing
let term_as_formula (t:term) : Tac formula =
match unsquash_term t with
| None -> F_Unknown
| Some t ->
term_as_formula' t
// Badly named, this only means it always returns a formula even if not properly
// squashed at the top-level.
let term_as_formula_total (t:term) : Tac formula =
term_as_formula' (maybe_unsquash_term t) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.NamedView.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Tactics.Common.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Stubs.Reflection.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.Types.fsti.checked",
"FStar.Reflection.V2.Derived.fst.checked",
"FStar.Reflection.Const.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.V2.Formula.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.NamedView",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.Common",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: FStar.Reflection.V2.Formula.formula -> FStar.Tactics.NamedView.term_view | Prims.Tot | [
"total"
] | [] | [
"FStar.Reflection.V2.Formula.formula",
"FStar.Tactics.NamedView.Tv_FVar",
"FStar.Stubs.Reflection.V2.Builtins.pack_fv",
"FStar.Reflection.Const.true_qn",
"FStar.Reflection.Const.false_qn",
"FStar.Tactics.NamedView.term",
"FStar.Reflection.Const.eq2_qn",
"Prims.Cons",
"FStar.Stubs.Reflection.V2.Data.argv",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.V2.Data.aqualv",
"Prims.Nil",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Reflection.Const.eq1_qn",
"FStar.Reflection.Const.lt_qn",
"FStar.Reflection.Const.lte_qn",
"FStar.Reflection.Const.gt_qn",
"FStar.Reflection.Const.gte_qn",
"FStar.Reflection.Const.and_qn",
"FStar.Reflection.Const.or_qn",
"FStar.Reflection.Const.imp_qn",
"FStar.Reflection.Const.not_qn",
"FStar.Reflection.Const.iff_qn",
"FStar.Tactics.NamedView.bv",
"FStar.Tactics.NamedView.Tv_Unknown",
"FStar.Tactics.NamedView.Tv_App",
"FStar.Stubs.Reflection.V2.Data.Q_Explicit",
"FStar.Tactics.NamedView.namedv",
"FStar.Tactics.NamedView.Tv_Var",
"FStar.Stubs.Reflection.Types.fv",
"Prims.int",
"FStar.Tactics.NamedView.Tv_Const",
"FStar.Stubs.Reflection.V2.Data.C_Int",
"FStar.Tactics.NamedView.term_view",
"FStar.Stubs.Reflection.V2.Data.Q_Implicit",
"FStar.Tactics.NamedView.named_term_view",
"Prims.list",
"FStar.List.Tot.Base.fold_left",
"FStar.Tactics.NamedView.pack"
] | [] | false | false | false | true | false | let formula_as_term_view (f: formula) : Tot term_view =
| let mk_app' tv args = List.Tot.Base.fold_left (fun tv a -> Tv_App (pack tv) a) tv args in
let e = Q_Explicit in
let i = Q_Implicit in
match f with
| True_ -> Tv_FVar (pack_fv true_qn)
| False_ -> Tv_FVar (pack_fv false_qn)
| Comp (Eq None) l r -> mk_app' (Tv_FVar (pack_fv eq2_qn)) [(l, e); (r, e)]
| Comp (Eq (Some t)) l r -> mk_app' (Tv_FVar (pack_fv eq2_qn)) [(t, i); (l, e); (r, e)]
| Comp (BoolEq None) l r -> mk_app' (Tv_FVar (pack_fv eq1_qn)) [(l, e); (r, e)]
| Comp (BoolEq (Some t)) l r -> mk_app' (Tv_FVar (pack_fv eq1_qn)) [(t, i); (l, e); (r, e)]
| Comp Lt l r -> mk_app' (Tv_FVar (pack_fv lt_qn)) [(l, e); (r, e)]
| Comp Le l r -> mk_app' (Tv_FVar (pack_fv lte_qn)) [(l, e); (r, e)]
| Comp Gt l r -> mk_app' (Tv_FVar (pack_fv gt_qn)) [(l, e); (r, e)]
| Comp Ge l r -> mk_app' (Tv_FVar (pack_fv gte_qn)) [(l, e); (r, e)]
| And p q -> mk_app' (Tv_FVar (pack_fv and_qn)) [(p, e); (q, e)]
| Or p q -> mk_app' (Tv_FVar (pack_fv or_qn)) [(p, e); (q, e)]
| Implies p q -> mk_app' (Tv_FVar (pack_fv imp_qn)) [(p, e); (q, e)]
| Not p -> mk_app' (Tv_FVar (pack_fv not_qn)) [(p, e)]
| Iff p q -> mk_app' (Tv_FVar (pack_fv iff_qn)) [(p, e); (q, e)]
| Forall b sort t -> Tv_Unknown
| Exists b sort t -> Tv_Unknown
| App p q -> Tv_App p (q, Q_Explicit)
| Name b -> Tv_Var b
| FV fv -> Tv_FVar fv
| IntLit i -> Tv_Const (C_Int i)
| F_Unknown -> Tv_Unknown | false |
FStar.Reflection.V2.Formula.fst | FStar.Reflection.V2.Formula.term_as_formula' | val term_as_formula' (t: term) : Tac formula | val term_as_formula' (t: term) : Tac formula | let term_as_formula' (t:term) : Tac formula =
match inspect_unascribe t with
| Tv_Var n ->
Name n
| Tv_FVar fv
| Tv_UInst fv _ ->
// Cannot use `when` clauses when verifying!
let qn = inspect_fv fv in
if qn = true_qn then True_
else if qn = false_qn then False_
else FV fv
// TODO: l_Forall
// ...or should we just try to drop all squashes?
// TODO: b2t at this point ?
| Tv_App h0 t -> begin
let (h, ts) = collect_app h0 in
let h = un_uinst h in
match inspect h, ts@[t] with
| Tv_FVar fv, [(a1, Q_Implicit); (a2, Q_Explicit); (a3, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = eq2_qn then Comp (Eq (Some a1)) a2 a3
else if qn = eq1_qn then Comp (BoolEq (Some a1)) a2 a3
else if qn = lt_qn then Comp Lt a2 a3
else if qn = lte_qn then Comp Le a2 a3
else if qn = gt_qn then Comp Gt a2 a3
else if qn = gte_qn then Comp Ge a2 a3
else App h0 (fst t)
| Tv_FVar fv, [(a1, Q_Explicit); (a2, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = imp_qn then Implies a1 a2
else if qn = and_qn then And a1 a2
else if qn = iff_qn then Iff a1 a2
else if qn = or_qn then Or a1 a2
// Non-annotated comparisons
else if qn = eq2_qn then Comp (Eq None) a1 a2
else if qn = eq1_qn then Comp (BoolEq None) a1 a2
else App h0 (fst t)
| Tv_FVar fv, [(a1, Q_Implicit); (a2, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = forall_qn then mk_Forall a1 a2
else if qn = exists_qn then mk_Exists a1 a2
else App h0 (fst t)
| Tv_FVar fv, [(a, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = not_qn then Not a
else if qn = b2t_qn then begin
if term_eq a (`false) then False_
else if term_eq a (`true) then True_
else App h0 (fst t)
end
else App h0 (fst t)
| _ ->
App h0 (fst t)
end
| Tv_Const (C_Int i) ->
IntLit i
(* Not formulas. *)
| Tv_Let _ _ _ _ _
| Tv_Match _ _ _
| Tv_Type _
| Tv_Abs _ _
| Tv_Arrow _ _
| Tv_Uvar _ _
| Tv_Unknown
| Tv_Unsupp
| Tv_Refine _ _ -> F_Unknown
(* Other constants? *)
| Tv_Const _ -> F_Unknown
(* Should not occur, we're using inspect *)
| Tv_BVar _ -> F_Unknown
| _ -> raise (TacticFailure "???") | {
"file_name": "ulib/FStar.Reflection.V2.Formula.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 163,
"start_col": 0,
"start_line": 86
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.V2.Formula
open FStar.List.Tot.Base
open FStar.Stubs.Reflection.Types
open FStar.Reflection.Const
open FStar.Stubs.Reflection.V2.Builtins
open FStar.Reflection.V2.Derived
open FStar.Stubs.Reflection.V2.Data
open FStar.Stubs.Tactics.Common
open FStar.Tactics.Effect
open FStar.Stubs.Tactics.V2.Builtins
open FStar.Tactics.NamedView
///// Helpers (we cannot use the ones in Tactics.V2.Derived, those are for named views /////
private let rec inspect_unascribe (t:term) : Tac term_view =
match inspect t with
| Tv_AscribedT t _ _ _
| Tv_AscribedC t _ _ _ ->
inspect_unascribe t
| tv -> tv
private let rec collect_app' (args : list argv) (t : term)
: Tac (term * list argv) (decreases t) =
match inspect_unascribe t with
| Tv_App l r ->
collect_app' (r::args) l
| _ -> (t, args)
private let collect_app = collect_app' []
/////
[@@plugin]
noeq type comparison =
| Eq of option typ (* Propositional equality (eq2), maybe annotated *)
| BoolEq of option typ (* Decidable, boolean equality (eq), maybe annotated *)
| Lt | Le | Gt | Ge (* Orderings, at type `int` (and subtypes) *)
[@@plugin]
noeq type formula =
| True_ : formula
| False_ : formula
| Comp : comparison -> term -> term -> formula
| And : term -> term -> formula
| Or : term -> term -> formula
| Not : term -> formula
| Implies: term -> term -> formula
| Iff : term -> term -> formula
| Forall : bv -> typ -> term -> formula
| Exists : bv -> typ -> term -> formula
| App : term -> term -> formula
| Name : namedv -> formula
| FV : fv -> formula
| IntLit : int -> formula
| F_Unknown : formula // Also a baked-in "None"
let mk_Forall (typ : term) (pred : term) : Tot formula =
let b = pack_bv ({ ppname = as_ppname "x";
sort = seal typ;
index = 0; }) in
Forall b typ (pack (Tv_App pred (pack (Tv_BVar b), Q_Explicit)))
let mk_Exists (typ : term) (pred : term) : Tot formula =
let b = pack_bv ({ ppname = as_ppname "x";
sort = seal typ;
index = 0; }) in
Exists b typ (pack (Tv_App pred (pack (Tv_BVar b), Q_Explicit))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.NamedView.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Tactics.Common.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Stubs.Reflection.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.Types.fsti.checked",
"FStar.Reflection.V2.Derived.fst.checked",
"FStar.Reflection.Const.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.V2.Formula.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.NamedView",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.Common",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac FStar.Reflection.V2.Formula.formula | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.namedv",
"FStar.Reflection.V2.Formula.Name",
"FStar.Reflection.V2.Formula.formula",
"FStar.Stubs.Reflection.Types.fv",
"Prims.op_Equality",
"Prims.list",
"Prims.string",
"FStar.Reflection.Const.true_qn",
"FStar.Reflection.V2.Formula.True_",
"Prims.bool",
"FStar.Reflection.Const.false_qn",
"FStar.Reflection.V2.Formula.False_",
"FStar.Reflection.V2.Formula.FV",
"FStar.Stubs.Reflection.Types.name",
"FStar.Stubs.Reflection.V2.Builtins.inspect_fv",
"FStar.Stubs.Reflection.V2.Data.universes",
"FStar.Stubs.Reflection.V2.Data.argv",
"FStar.Stubs.Reflection.Types.term",
"FStar.Reflection.Const.eq2_qn",
"FStar.Reflection.V2.Formula.Comp",
"FStar.Reflection.V2.Formula.Eq",
"FStar.Pervasives.Native.Some",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Reflection.Const.eq1_qn",
"FStar.Reflection.V2.Formula.BoolEq",
"FStar.Reflection.Const.lt_qn",
"FStar.Reflection.V2.Formula.Lt",
"FStar.Reflection.Const.lte_qn",
"FStar.Reflection.V2.Formula.Le",
"FStar.Reflection.Const.gt_qn",
"FStar.Reflection.V2.Formula.Gt",
"FStar.Reflection.Const.gte_qn",
"FStar.Reflection.V2.Formula.Ge",
"FStar.Reflection.V2.Formula.App",
"FStar.Pervasives.Native.fst",
"FStar.Stubs.Reflection.V2.Data.aqualv",
"FStar.Reflection.Const.imp_qn",
"FStar.Reflection.V2.Formula.Implies",
"FStar.Reflection.Const.and_qn",
"FStar.Reflection.V2.Formula.And",
"FStar.Reflection.Const.iff_qn",
"FStar.Reflection.V2.Formula.Iff",
"FStar.Reflection.Const.or_qn",
"FStar.Reflection.V2.Formula.Or",
"FStar.Pervasives.Native.None",
"FStar.Reflection.Const.forall_qn",
"FStar.Reflection.V2.Formula.mk_Forall",
"FStar.Reflection.Const.exists_qn",
"FStar.Reflection.V2.Formula.mk_Exists",
"FStar.Reflection.Const.not_qn",
"FStar.Reflection.V2.Formula.Not",
"FStar.Reflection.Const.b2t_qn",
"FStar.Stubs.Reflection.V2.Builtins.term_eq",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.named_term_view",
"FStar.Pervasives.Native.Mktuple2",
"FStar.List.Tot.Base.op_At",
"Prims.Cons",
"Prims.Nil",
"FStar.Tactics.NamedView.inspect",
"FStar.Reflection.V2.Derived.un_uinst",
"FStar.Reflection.V2.Formula.collect_app",
"Prims.int",
"FStar.Reflection.V2.Formula.IntLit",
"FStar.Tactics.NamedView.simple_binder",
"FStar.Reflection.V2.Formula.F_Unknown",
"FStar.Pervasives.Native.option",
"FStar.Tactics.NamedView.match_returns_ascription",
"FStar.Tactics.NamedView.branch",
"FStar.Tactics.NamedView.universe",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.comp",
"Prims.nat",
"FStar.Stubs.Reflection.Types.ctx_uvar_and_subst",
"FStar.Stubs.Reflection.V2.Data.vconst",
"FStar.Tactics.NamedView.bv",
"FStar.Tactics.Effect.raise",
"FStar.Stubs.Tactics.Common.TacticFailure",
"FStar.Tactics.NamedView.term_view",
"FStar.Reflection.V2.Formula.inspect_unascribe"
] | [] | false | true | false | false | false | let term_as_formula' (t: term) : Tac formula =
| match inspect_unascribe t with
| Tv_Var n -> Name n
| Tv_FVar fv
| Tv_UInst fv _ ->
let qn = inspect_fv fv in
if qn = true_qn then True_ else if qn = false_qn then False_ else FV fv
| Tv_App h0 t ->
let h, ts = collect_app h0 in
let h = un_uinst h in
(match inspect h, ts @ [t] with
| Tv_FVar fv, [a1, Q_Implicit ; a2, Q_Explicit ; a3, Q_Explicit] ->
let qn = inspect_fv fv in
if qn = eq2_qn
then Comp (Eq (Some a1)) a2 a3
else
if qn = eq1_qn
then Comp (BoolEq (Some a1)) a2 a3
else
if qn = lt_qn
then Comp Lt a2 a3
else
if qn = lte_qn
then Comp Le a2 a3
else
if qn = gt_qn
then Comp Gt a2 a3
else if qn = gte_qn then Comp Ge a2 a3 else App h0 (fst t)
| Tv_FVar fv, [a1, Q_Explicit ; a2, Q_Explicit] ->
let qn = inspect_fv fv in
if qn = imp_qn
then Implies a1 a2
else
if qn = and_qn
then And a1 a2
else
if qn = iff_qn
then Iff a1 a2
else
if qn = or_qn
then Or a1 a2
else
if qn = eq2_qn
then Comp (Eq None) a1 a2
else if qn = eq1_qn then Comp (BoolEq None) a1 a2 else App h0 (fst t)
| Tv_FVar fv, [a1, Q_Implicit ; a2, Q_Explicit] ->
let qn = inspect_fv fv in
if qn = forall_qn
then mk_Forall a1 a2
else if qn = exists_qn then mk_Exists a1 a2 else App h0 (fst t)
| Tv_FVar fv, [a, Q_Explicit] ->
let qn = inspect_fv fv in
if qn = not_qn
then Not a
else
if qn = b2t_qn
then
if term_eq a (`false) then False_ else if term_eq a (`true) then True_ else App h0 (fst t)
else App h0 (fst t)
| _ -> App h0 (fst t))
| Tv_Const (C_Int i) -> IntLit i
| Tv_Let _ _ _ _ _
| Tv_Match _ _ _
| Tv_Type _
| Tv_Abs _ _
| Tv_Arrow _ _
| Tv_Uvar _ _
| Tv_Unknown
| Tv_Unsupp
| Tv_Refine _ _ -> F_Unknown
| Tv_Const _ -> F_Unknown
| Tv_BVar _ -> F_Unknown
| _ -> raise (TacticFailure "???") | false |
FStar.Reflection.V2.Formula.fst | FStar.Reflection.V2.Formula.formula_to_string | val formula_to_string (f: formula) : Tac string | val formula_to_string (f: formula) : Tac string | let formula_to_string (f:formula) : Tac string =
match f with
| True_ -> "True_"
| False_ -> "False_"
| Comp (Eq mt) l r -> "Eq" ^
(match mt with
| None -> ""
| Some t -> " (" ^ term_to_string t ^ ")") ^
" (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp (BoolEq mt) l r -> "BoolEq" ^
(match mt with
| None -> ""
| Some t -> " (" ^ term_to_string t ^ ")") ^
" (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp Lt l r -> "Lt (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp Le l r -> "Le (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp Gt l r -> "Gt (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp Ge l r -> "Ge (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| And p q -> "And (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Or p q -> "Or (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Implies p q -> "Implies (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Not p -> "Not (" ^ term_to_string p ^ ")"
| Iff p q -> "Iff (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Forall bs _sort t -> "Forall <bs> (" ^ term_to_string t ^ ")"
| Exists bs _sort t -> "Exists <bs> (" ^ term_to_string t ^ ")"
| App p q -> "App (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Name bv -> "Name (" ^ namedv_to_string bv ^ ")"
| FV fv -> "FV (" ^ flatten_name (inspect_fv fv) ^ ")"
| IntLit i -> "Int " ^ string_of_int i
| F_Unknown -> "?" | {
"file_name": "ulib/FStar.Reflection.V2.Formula.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 22,
"end_line": 251,
"start_col": 0,
"start_line": 222
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.V2.Formula
open FStar.List.Tot.Base
open FStar.Stubs.Reflection.Types
open FStar.Reflection.Const
open FStar.Stubs.Reflection.V2.Builtins
open FStar.Reflection.V2.Derived
open FStar.Stubs.Reflection.V2.Data
open FStar.Stubs.Tactics.Common
open FStar.Tactics.Effect
open FStar.Stubs.Tactics.V2.Builtins
open FStar.Tactics.NamedView
///// Helpers (we cannot use the ones in Tactics.V2.Derived, those are for named views /////
private let rec inspect_unascribe (t:term) : Tac term_view =
match inspect t with
| Tv_AscribedT t _ _ _
| Tv_AscribedC t _ _ _ ->
inspect_unascribe t
| tv -> tv
private let rec collect_app' (args : list argv) (t : term)
: Tac (term * list argv) (decreases t) =
match inspect_unascribe t with
| Tv_App l r ->
collect_app' (r::args) l
| _ -> (t, args)
private let collect_app = collect_app' []
/////
[@@plugin]
noeq type comparison =
| Eq of option typ (* Propositional equality (eq2), maybe annotated *)
| BoolEq of option typ (* Decidable, boolean equality (eq), maybe annotated *)
| Lt | Le | Gt | Ge (* Orderings, at type `int` (and subtypes) *)
[@@plugin]
noeq type formula =
| True_ : formula
| False_ : formula
| Comp : comparison -> term -> term -> formula
| And : term -> term -> formula
| Or : term -> term -> formula
| Not : term -> formula
| Implies: term -> term -> formula
| Iff : term -> term -> formula
| Forall : bv -> typ -> term -> formula
| Exists : bv -> typ -> term -> formula
| App : term -> term -> formula
| Name : namedv -> formula
| FV : fv -> formula
| IntLit : int -> formula
| F_Unknown : formula // Also a baked-in "None"
let mk_Forall (typ : term) (pred : term) : Tot formula =
let b = pack_bv ({ ppname = as_ppname "x";
sort = seal typ;
index = 0; }) in
Forall b typ (pack (Tv_App pred (pack (Tv_BVar b), Q_Explicit)))
let mk_Exists (typ : term) (pred : term) : Tot formula =
let b = pack_bv ({ ppname = as_ppname "x";
sort = seal typ;
index = 0; }) in
Exists b typ (pack (Tv_App pred (pack (Tv_BVar b), Q_Explicit)))
[@@plugin]
let term_as_formula' (t:term) : Tac formula =
match inspect_unascribe t with
| Tv_Var n ->
Name n
| Tv_FVar fv
| Tv_UInst fv _ ->
// Cannot use `when` clauses when verifying!
let qn = inspect_fv fv in
if qn = true_qn then True_
else if qn = false_qn then False_
else FV fv
// TODO: l_Forall
// ...or should we just try to drop all squashes?
// TODO: b2t at this point ?
| Tv_App h0 t -> begin
let (h, ts) = collect_app h0 in
let h = un_uinst h in
match inspect h, ts@[t] with
| Tv_FVar fv, [(a1, Q_Implicit); (a2, Q_Explicit); (a3, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = eq2_qn then Comp (Eq (Some a1)) a2 a3
else if qn = eq1_qn then Comp (BoolEq (Some a1)) a2 a3
else if qn = lt_qn then Comp Lt a2 a3
else if qn = lte_qn then Comp Le a2 a3
else if qn = gt_qn then Comp Gt a2 a3
else if qn = gte_qn then Comp Ge a2 a3
else App h0 (fst t)
| Tv_FVar fv, [(a1, Q_Explicit); (a2, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = imp_qn then Implies a1 a2
else if qn = and_qn then And a1 a2
else if qn = iff_qn then Iff a1 a2
else if qn = or_qn then Or a1 a2
// Non-annotated comparisons
else if qn = eq2_qn then Comp (Eq None) a1 a2
else if qn = eq1_qn then Comp (BoolEq None) a1 a2
else App h0 (fst t)
| Tv_FVar fv, [(a1, Q_Implicit); (a2, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = forall_qn then mk_Forall a1 a2
else if qn = exists_qn then mk_Exists a1 a2
else App h0 (fst t)
| Tv_FVar fv, [(a, Q_Explicit)] ->
let qn = inspect_fv fv in
if qn = not_qn then Not a
else if qn = b2t_qn then begin
if term_eq a (`false) then False_
else if term_eq a (`true) then True_
else App h0 (fst t)
end
else App h0 (fst t)
| _ ->
App h0 (fst t)
end
| Tv_Const (C_Int i) ->
IntLit i
(* Not formulas. *)
| Tv_Let _ _ _ _ _
| Tv_Match _ _ _
| Tv_Type _
| Tv_Abs _ _
| Tv_Arrow _ _
| Tv_Uvar _ _
| Tv_Unknown
| Tv_Unsupp
| Tv_Refine _ _ -> F_Unknown
(* Other constants? *)
| Tv_Const _ -> F_Unknown
(* Should not occur, we're using inspect *)
| Tv_BVar _ -> F_Unknown
| _ -> raise (TacticFailure "???")
// Unsquashing
let term_as_formula (t:term) : Tac formula =
match unsquash_term t with
| None -> F_Unknown
| Some t ->
term_as_formula' t
// Badly named, this only means it always returns a formula even if not properly
// squashed at the top-level.
let term_as_formula_total (t:term) : Tac formula =
term_as_formula' (maybe_unsquash_term t)
let formula_as_term_view (f:formula) : Tot term_view =
let mk_app' tv args = List.Tot.Base.fold_left (fun tv a -> Tv_App (pack tv) a) tv args in
let e = Q_Explicit in
let i = Q_Implicit in
match f with
| True_ -> Tv_FVar (pack_fv true_qn)
| False_ -> Tv_FVar (pack_fv false_qn)
| Comp (Eq None) l r -> mk_app' (Tv_FVar (pack_fv eq2_qn)) [(l,e);(r,e)]
| Comp (Eq (Some t)) l r -> mk_app' (Tv_FVar (pack_fv eq2_qn)) [(t,i);(l,e);(r,e)]
| Comp (BoolEq None) l r -> mk_app' (Tv_FVar (pack_fv eq1_qn)) [(l,e);(r,e)]
| Comp (BoolEq (Some t)) l r -> mk_app' (Tv_FVar (pack_fv eq1_qn)) [(t,i);(l,e);(r,e)]
| Comp Lt l r -> mk_app' (Tv_FVar (pack_fv lt_qn)) [(l,e);(r,e)]
| Comp Le l r -> mk_app' (Tv_FVar (pack_fv lte_qn)) [(l,e);(r,e)]
| Comp Gt l r -> mk_app' (Tv_FVar (pack_fv gt_qn)) [(l,e);(r,e)]
| Comp Ge l r -> mk_app' (Tv_FVar (pack_fv gte_qn)) [(l,e);(r,e)]
| And p q -> mk_app' (Tv_FVar (pack_fv and_qn)) [(p,e);(q,e)]
| Or p q -> mk_app' (Tv_FVar (pack_fv or_qn)) [(p,e);(q,e)]
| Implies p q -> mk_app' (Tv_FVar (pack_fv imp_qn)) [(p,e);(q,e)]
| Not p -> mk_app' (Tv_FVar (pack_fv not_qn)) [(p,e)]
| Iff p q -> mk_app' (Tv_FVar (pack_fv iff_qn)) [(p,e);(q,e)]
| Forall b sort t -> Tv_Unknown // TODO: decide on meaning of this
| Exists b sort t -> Tv_Unknown // TODO: ^
| App p q ->
Tv_App p (q, Q_Explicit)
| Name b ->
Tv_Var b
| FV fv ->
Tv_FVar fv
| IntLit i ->
Tv_Const (C_Int i)
| F_Unknown ->
Tv_Unknown
let formula_as_term (f:formula) : Tot term =
pack (formula_as_term_view f)
private let namedv_to_string (namedv : namedv) : Tac string =
let namedvv = inspect_namedv namedv in
unseal namedvv.ppname | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.NamedView.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Tactics.Common.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Stubs.Reflection.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.Types.fsti.checked",
"FStar.Reflection.V2.Derived.fst.checked",
"FStar.Reflection.Const.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.V2.Formula.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.NamedView",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.Common",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Derived",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.Const",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Reflection.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: FStar.Reflection.V2.Formula.formula -> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Reflection.V2.Formula.formula",
"Prims.string",
"FStar.Pervasives.Native.option",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Tactics.NamedView.term",
"Prims.op_Hat",
"FStar.Stubs.Tactics.V2.Builtins.term_to_string",
"FStar.Tactics.NamedView.bv",
"FStar.Tactics.NamedView.namedv",
"FStar.Reflection.V2.Formula.namedv_to_string",
"FStar.Stubs.Reflection.Types.fv",
"FStar.Reflection.V2.Derived.flatten_name",
"FStar.Stubs.Reflection.V2.Builtins.inspect_fv",
"Prims.int",
"Prims.string_of_int"
] | [] | false | true | false | false | false | let formula_to_string (f: formula) : Tac string =
| match f with
| True_ -> "True_"
| False_ -> "False_"
| Comp (Eq mt) l r ->
"Eq" ^
(match mt with
| None -> ""
| Some t -> " (" ^ term_to_string t ^ ")") ^
" (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp (BoolEq mt) l r ->
"BoolEq" ^
(match mt with
| None -> ""
| Some t -> " (" ^ term_to_string t ^ ")") ^
" (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp Lt l r -> "Lt (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp Le l r -> "Le (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp Gt l r -> "Gt (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| Comp Ge l r -> "Ge (" ^ term_to_string l ^ ") (" ^ term_to_string r ^ ")"
| And p q -> "And (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Or p q -> "Or (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Implies p q -> "Implies (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Not p -> "Not (" ^ term_to_string p ^ ")"
| Iff p q -> "Iff (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Forall bs _sort t -> "Forall <bs> (" ^ term_to_string t ^ ")"
| Exists bs _sort t -> "Exists <bs> (" ^ term_to_string t ^ ")"
| App p q -> "App (" ^ term_to_string p ^ ") (" ^ term_to_string q ^ ")"
| Name bv -> "Name (" ^ namedv_to_string bv ^ ")"
| FV fv -> "FV (" ^ flatten_name (inspect_fv fv) ^ ")"
| IntLit i -> "Int " ^ string_of_int i
| F_Unknown -> "?" | false |
Hacl.Impl.Chacha20Poly1305.fst | Hacl.Impl.Chacha20Poly1305.poly1305_do_ | val poly1305_do_:
#w:field_spec
-> k:lbuffer uint8 32ul // key
-> aadlen:size_t
-> aad:lbuffer uint8 aadlen // authenticated additional data
-> mlen:size_t
-> m:lbuffer uint8 mlen // plaintext
-> ctx:Poly.poly1305_ctx w
-> block:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h k /\ live h aad /\ live h m /\ live h ctx /\ live h block /\
disjoint ctx k /\ disjoint ctx aad /\ disjoint ctx m /\ disjoint ctx block /\
disjoint block k /\ disjoint block aad /\ disjoint block m)
(ensures fun h0 _ h1 ->
modifies (loc ctx |+| loc block) h0 h1 /\
(let acc, r = SpecPoly.poly1305_init (as_seq h0 k) in
let acc = if (length aad <> 0) then Spec.poly1305_padded r (as_seq h0 aad) acc else acc in
let acc = if (length m <> 0) then Spec.poly1305_padded r (as_seq h0 m) acc else acc in
let block_s = LSeq.concat (BSeq.uint_to_bytes_le #U64 (u64 (length aad)))
(BSeq.uint_to_bytes_le #U64 (u64 (length m))) in
let acc = SpecPoly.poly1305_update1 r 16 block_s acc in
Poly.as_get_acc h1 ctx == acc /\ as_seq h1 block == block_s /\
Poly.state_inv_t h1 ctx)) | val poly1305_do_:
#w:field_spec
-> k:lbuffer uint8 32ul // key
-> aadlen:size_t
-> aad:lbuffer uint8 aadlen // authenticated additional data
-> mlen:size_t
-> m:lbuffer uint8 mlen // plaintext
-> ctx:Poly.poly1305_ctx w
-> block:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h k /\ live h aad /\ live h m /\ live h ctx /\ live h block /\
disjoint ctx k /\ disjoint ctx aad /\ disjoint ctx m /\ disjoint ctx block /\
disjoint block k /\ disjoint block aad /\ disjoint block m)
(ensures fun h0 _ h1 ->
modifies (loc ctx |+| loc block) h0 h1 /\
(let acc, r = SpecPoly.poly1305_init (as_seq h0 k) in
let acc = if (length aad <> 0) then Spec.poly1305_padded r (as_seq h0 aad) acc else acc in
let acc = if (length m <> 0) then Spec.poly1305_padded r (as_seq h0 m) acc else acc in
let block_s = LSeq.concat (BSeq.uint_to_bytes_le #U64 (u64 (length aad)))
(BSeq.uint_to_bytes_le #U64 (u64 (length m))) in
let acc = SpecPoly.poly1305_update1 r 16 block_s acc in
Poly.as_get_acc h1 ctx == acc /\ as_seq h1 block == block_s /\
Poly.state_inv_t h1 ctx)) | let poly1305_do_ #w k aadlen aad mlen m ctx block =
Poly.poly1305_init ctx k;
if (aadlen <> 0ul) then (
poly1305_padded ctx aadlen aad)
else ();
if (mlen <> 0ul) then (
poly1305_padded ctx mlen m)
else ();
let h0 = ST.get () in
update_sub_f h0 block 0ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 (to_u64 aadlen))
(fun _ -> uint_to_bytes_le (sub block 0ul 8ul) (to_u64 aadlen));
let h1 = ST.get () in
//assert (LSeq.sub (as_seq h1 block) 0 8 == BSeq.uint_to_bytes_le #U64 (to_u64 aadlen));
Poly.reveal_ctx_inv ctx h0 h1;
update_sub_f h1 block 8ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 (to_u64 mlen))
(fun _ -> uint_to_bytes_le (sub block 8ul 8ul) (to_u64 mlen));
let h2 = ST.get () in
//assert (LSeq.sub (as_seq h2 block) 8 8 == BSeq.uint_to_bytes_le #U64 (to_u64 mlen));
LSeq.eq_intro (LSeq.sub (as_seq h2 block) 0 8) (BSeq.uint_to_bytes_le #U64 (to_u64 aadlen));
LSeq.lemma_concat2 8 (BSeq.uint_to_bytes_le #U64 (to_u64 aadlen)) 8 (BSeq.uint_to_bytes_le #U64 (to_u64 mlen)) (as_seq h2 block);
//assert (as_seq h2 block == LSeq.concat (BSeq.uint_to_bytes_le #U64 (to_u64 aadlen)) (BSeq.uint_to_bytes_le #U64 (to_u64 mlen)));
Poly.reveal_ctx_inv ctx h1 h2;
Poly.poly1305_update1 ctx block | {
"file_name": "code/chacha20poly1305/Hacl.Impl.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 73,
"start_col": 0,
"start_line": 49
} | module Hacl.Impl.Chacha20Poly1305
open FStar.HyperStack.All
open FStar.HyperStack
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Chacha20Poly1305.PolyCore
open Hacl.Impl.Poly1305.Fields
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Spec = Spec.Chacha20Poly1305
module SpecPoly = Spec.Poly1305
module Poly = Hacl.Impl.Poly1305
#reset-options "--z3rlimit 150 --max_fuel 0 --max_ifuel 1 --record_options"
val poly1305_do_:
#w:field_spec
-> k:lbuffer uint8 32ul // key
-> aadlen:size_t
-> aad:lbuffer uint8 aadlen // authenticated additional data
-> mlen:size_t
-> m:lbuffer uint8 mlen // plaintext
-> ctx:Poly.poly1305_ctx w
-> block:lbuffer uint8 16ul ->
Stack unit
(requires fun h ->
live h k /\ live h aad /\ live h m /\ live h ctx /\ live h block /\
disjoint ctx k /\ disjoint ctx aad /\ disjoint ctx m /\ disjoint ctx block /\
disjoint block k /\ disjoint block aad /\ disjoint block m)
(ensures fun h0 _ h1 ->
modifies (loc ctx |+| loc block) h0 h1 /\
(let acc, r = SpecPoly.poly1305_init (as_seq h0 k) in
let acc = if (length aad <> 0) then Spec.poly1305_padded r (as_seq h0 aad) acc else acc in
let acc = if (length m <> 0) then Spec.poly1305_padded r (as_seq h0 m) acc else acc in
let block_s = LSeq.concat (BSeq.uint_to_bytes_le #U64 (u64 (length aad)))
(BSeq.uint_to_bytes_le #U64 (u64 (length m))) in
let acc = SpecPoly.poly1305_update1 r 16 block_s acc in
Poly.as_get_acc h1 ctx == acc /\ as_seq h1 block == block_s /\
Poly.state_inv_t h1 ctx)) | {
"checked_file": "/",
"dependencies": [
"Spec.Poly1305.fst.checked",
"Spec.Chacha20Poly1305.fst.checked",
"Spec.Chacha20.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Chacha20.Vec.fst.checked",
"Hacl.Impl.Poly1305.Fields.fst.checked",
"Hacl.Impl.Poly1305.fsti.checked",
"Hacl.Impl.Chacha20Poly1305.PolyCore.fst.checked",
"Hacl.Impl.Chacha20.Vec.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Poly1305",
"short_module": "Poly"
},
{
"abbrev": true,
"full_module": "Spec.Poly1305",
"short_module": "SpecPoly"
},
{
"abbrev": true,
"full_module": "Spec.Chacha20Poly1305",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Chacha20Poly1305.PolyCore",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
aadlen: Lib.IntTypes.size_t ->
aad: Lib.Buffer.lbuffer Lib.IntTypes.uint8 aadlen ->
mlen: Lib.IntTypes.size_t ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
ctx: Hacl.Impl.Poly1305.poly1305_ctx w ->
block: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Poly1305.Fields.field_spec",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Hacl.Impl.Poly1305.poly1305_ctx",
"Hacl.Impl.Poly1305.poly1305_update1",
"Prims.unit",
"Hacl.Impl.Poly1305.reveal_ctx_inv",
"Lib.Sequence.lemma_concat2",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.uint_to_bytes_le",
"Lib.IntTypes.U64",
"Lib.IntTypes.to_u64",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.Sequence.eq_intro",
"Lib.Sequence.sub",
"Lib.IntTypes.v",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.update_sub_f",
"Lib.Sequence.lseq",
"Lib.ByteBuffer.uint_to_bytes_le",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub",
"Prims.op_disEquality",
"FStar.UInt32.t",
"Hacl.Impl.Chacha20Poly1305.PolyCore.poly1305_padded",
"Prims.bool",
"Hacl.Impl.Poly1305.poly1305_init"
] | [] | false | true | false | false | false | let poly1305_do_ #w k aadlen aad mlen m ctx block =
| Poly.poly1305_init ctx k;
if (aadlen <> 0ul) then (poly1305_padded ctx aadlen aad);
if (mlen <> 0ul) then (poly1305_padded ctx mlen m);
let h0 = ST.get () in
update_sub_f h0
block
0ul
8ul
(fun h -> BSeq.uint_to_bytes_le #U64 (to_u64 aadlen))
(fun _ -> uint_to_bytes_le (sub block 0ul 8ul) (to_u64 aadlen));
let h1 = ST.get () in
Poly.reveal_ctx_inv ctx h0 h1;
update_sub_f h1
block
8ul
8ul
(fun h -> BSeq.uint_to_bytes_le #U64 (to_u64 mlen))
(fun _ -> uint_to_bytes_le (sub block 8ul 8ul) (to_u64 mlen));
let h2 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h2 block) 0 8) (BSeq.uint_to_bytes_le #U64 (to_u64 aadlen));
LSeq.lemma_concat2 8
(BSeq.uint_to_bytes_le #U64 (to_u64 aadlen))
8
(BSeq.uint_to_bytes_le #U64 (to_u64 mlen))
(as_seq h2 block);
Poly.reveal_ctx_inv ctx h1 h2;
Poly.poly1305_update1 ctx block | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.is_valid_kem | val is_valid_kem : _: (Spec.Agile.DH.algorithm * Spec.Hash.Definitions.hash_alg) -> Prims.bool | let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 25,
"start_col": 0,
"start_line": 22
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: (Spec.Agile.DH.algorithm * Spec.Hash.Definitions.hash_alg) -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.tuple2",
"Spec.Agile.DH.algorithm",
"Spec.Hash.Definitions.hash_alg",
"Prims.bool"
] | [] | false | false | false | true | false | let is_valid_kem =
| function
| DH.DH_Curve25519, Hash.SHA2_256 | DH.DH_P256, Hash.SHA2_256 -> true
| _, _ -> false | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.is_valid_ciphersuite | val is_valid_ciphersuite (cs: DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool | val is_valid_ciphersuite (cs: DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool | let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 83,
"end_line": 48,
"start_col": 0,
"start_line": 46
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a} | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
cs:
(((Spec.Agile.DH.algorithm * Spec.Agile.HPKE.hash_algorithm) * Spec.Agile.HPKE.aead) *
Spec.Hash.Definitions.hash_alg)
-> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.tuple4",
"Spec.Agile.DH.algorithm",
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.aead",
"Spec.Hash.Definitions.hash_alg",
"Prims.op_AmpAmp",
"Spec.Agile.HPKE.is_valid_kem",
"FStar.Pervasives.Native.Mktuple2",
"Spec.Agile.HPKE.is_valid_aead",
"Spec.Agile.HPKE.is_valid_hash",
"Prims.bool"
] | [] | false | false | false | true | false | let is_valid_ciphersuite (cs: DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
| let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.is_valid_aead | val is_valid_aead : _: Spec.Agile.HPKE.aead -> Prims.bool | let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 36,
"start_col": 0,
"start_line": 31
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Spec.Agile.HPKE.aead -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.aead",
"Prims.bool"
] | [] | false | false | false | true | false | let is_valid_aead =
| function
| Seal AEAD.AES128_GCM | Seal AEAD.AES256_GCM | Seal AEAD.CHACHA20_POLY1305 | ExportOnly -> true
| _ -> false | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.hash_algorithm | val hash_algorithm : Type0 | let hash_algorithm = a:Hash.hash_alg{is_valid_hash a} | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 44,
"start_col": 0,
"start_line": 44
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.Agile.HPKE.is_valid_hash"
] | [] | false | false | false | true | true | let hash_algorithm =
| a: Hash.hash_alg{is_valid_hash a} | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.aead_of_cs | val aead_of_cs (cs: ciphersuite) : aead | val aead_of_cs (cs: ciphersuite) : aead | let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 62,
"start_col": 0,
"start_line": 61
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Spec.Agile.HPKE.aead | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.DH.algorithm",
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.aead",
"Spec.Hash.Definitions.hash_alg"
] | [] | false | false | false | true | false | let aead_of_cs (cs: ciphersuite) : aead =
| let _, _, a, _ = cs in
a | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.is_valid_hash | val is_valid_hash : _: Spec.Hash.Definitions.hash_alg -> Prims.bool | let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 42,
"start_col": 0,
"start_line": 38
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Spec.Hash.Definitions.hash_alg -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.bool"
] | [] | false | false | false | true | false | let is_valid_hash =
| function
| Hash.SHA2_256 | Hash.SHA2_384 | Hash.SHA2_512 -> true
| _ -> false | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.ciphersuite | val ciphersuite : Type0 | let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs} | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 100,
"end_line": 50,
"start_col": 0,
"start_line": 50
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.tuple4",
"Spec.Agile.DH.algorithm",
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.aead",
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.Agile.HPKE.is_valid_ciphersuite"
] | [] | false | false | false | true | true | let ciphersuite =
| cs: (DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs} | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.kem_dh_of_cs | val kem_dh_of_cs (cs: ciphersuite) : DH.algorithm | val kem_dh_of_cs (cs: ciphersuite) : DH.algorithm | let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 54,
"start_col": 0,
"start_line": 53
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs} | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Spec.Agile.DH.algorithm | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.DH.algorithm",
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.aead",
"Spec.Hash.Definitions.hash_alg"
] | [] | false | false | false | true | false | let kem_dh_of_cs (cs: ciphersuite) : DH.algorithm =
| let c, _, _, _ = cs in
c | false |
Vale.AsLowStar.Wrapper.fsti | Vale.AsLowStar.Wrapper.prediction_post_rel | val prediction_post_rel
(#max_arity: nat)
(post: VSig.vale_post_tl [])
(code: V.va_code)
(args: IX64.arg_list)
: IX64.prediction_post_rel_t code args | val prediction_post_rel
(#max_arity: nat)
(post: VSig.vale_post_tl [])
(code: V.va_code)
(args: IX64.arg_list)
: IX64.prediction_post_rel_t code args | let prediction_post_rel
(#max_arity:nat)
(post:VSig.vale_post_tl [])
(code:V.va_code)
(args:IX64.arg_list)
: IX64.prediction_post_rel_t code args
=
fun
(h0:mem_roots args)
(_s0:BS.machine_state)
(rax_fuel_mem:(UInt64.t & nat & interop_heap))
(s1:BS.machine_state) ->
let rax, fuel, mem = rax_fuel_mem in
exists h1.
h1 == hs_of_mem mem /\
mem_roots_p h1 args /\
LSig.(to_low_post post args h0 rax h1) | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 54,
"start_col": 0,
"start_line": 38
} | module Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
[@__reduce__]
let prediction_pre_rel
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(pre:VSig.vale_pre_tl [])
(code:V.va_code)
(args:IX64.arg_list)
: IX64.prediction_pre_rel_t code args
=
fun (h0:mem_roots args) ->
LSig.(to_low_pre #max_arity #arg_reg pre args h0) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.Wrapper.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
post: Vale.AsLowStar.ValeSig.vale_post_tl [] ->
code: Vale.X64.Decls.va_code ->
args: Vale.Interop.X64.arg_list
-> Vale.Interop.X64.prediction_post_rel_t code args | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.AsLowStar.ValeSig.vale_post_tl",
"Prims.Nil",
"Vale.Interop.Base.td",
"Vale.X64.Decls.va_code",
"Vale.Interop.X64.arg_list",
"Vale.Interop.Base.mem_roots",
"Vale.X64.Machine_Semantics_s.machine_state",
"FStar.Pervasives.Native.tuple3",
"FStar.UInt64.t",
"Vale.Interop.Heap_s.interop_heap",
"Prims.l_Exists",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"Prims.l_and",
"Prims.eq2",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.AsLowStar.LowStarSig.to_low_post",
"Prims.prop",
"Vale.Interop.X64.prediction_post_rel_t"
] | [] | false | false | false | false | false | let prediction_post_rel
(#max_arity: nat)
(post: VSig.vale_post_tl [])
(code: V.va_code)
(args: IX64.arg_list)
: IX64.prediction_post_rel_t code args =
| fun
(h0: mem_roots args)
(_s0: BS.machine_state)
(rax_fuel_mem: (UInt64.t & nat & interop_heap))
(s1: BS.machine_state)
->
let rax, fuel, mem = rax_fuel_mem in
exists h1. h1 == hs_of_mem mem /\ mem_roots_p h1 args /\ LSig.(to_low_post post args h0 rax h1) | false |
MerkleTree.New.High.Correct.Path.fst | MerkleTree.New.High.Correct.Path.mt_get_path_inv_ok | val mt_get_path_inv_ok:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
idx:nat{MT?.i mt <= idx && idx < MT?.j mt} ->
drt:hash ->
Lemma (requires (MT?.j mt > 0 /\ mt_inv mt olds))
(ensures (let j, p, rt = mt_get_path mt idx drt in
j == MT?.j mt /\
mt_root_inv #_ #(MT?.hash_fun mt) (mt_base mt olds) hash_init false rt /\
S.head p == S.index (mt_base mt olds) idx /\
(assert (S.length (S.tail p) == mt_path_length idx (MT?.j mt) false);
S.equal (path_spec idx (MT?.j mt) false (S.tail p))
(MTS.mt_get_path #_ #(MT?.hash_fun mt) #(log2c j) (mt_spec mt olds) idx)))) | val mt_get_path_inv_ok:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
idx:nat{MT?.i mt <= idx && idx < MT?.j mt} ->
drt:hash ->
Lemma (requires (MT?.j mt > 0 /\ mt_inv mt olds))
(ensures (let j, p, rt = mt_get_path mt idx drt in
j == MT?.j mt /\
mt_root_inv #_ #(MT?.hash_fun mt) (mt_base mt olds) hash_init false rt /\
S.head p == S.index (mt_base mt olds) idx /\
(assert (S.length (S.tail p) == mt_path_length idx (MT?.j mt) false);
S.equal (path_spec idx (MT?.j mt) false (S.tail p))
(MTS.mt_get_path #_ #(MT?.hash_fun mt) #(log2c j) (mt_spec mt olds) idx)))) | let mt_get_path_inv_ok #hsz mt olds idx drt =
let j, p, rt = mt_get_path mt idx drt in
mt_get_root_inv_ok mt drt olds;
assert (j == MT?.j mt);
assert (mt_root_inv #_ #(MT?.hash_fun mt) (mt_base mt olds) hash_init false rt);
let ofs = offset_of (MT?.i mt) in
let umt, _ = mt_get_root mt drt in
let ip = path_insert S.empty (S.index (mt_base mt olds) idx) in
mt_get_path_unchanged 0 (MT?.hs umt) (MT?.rhs umt)
(MT?.i umt) (MT?.j umt) idx ip false;
assert (S.head ip == S.head (S.slice p 0 (S.length ip)));
assert (S.head ip == S.head p);
assert (S.head p == S.index (mt_base mt olds) idx);
assert (S.length (S.tail p) == mt_path_length idx (MT?.j mt) false);
mt_get_path_inv_ok_ #_ #(MT?.hash_fun mt) 0 (MT?.i umt) (MT?.j umt)
olds (MT?.hs umt) (MT?.rhs umt) idx ip hash_init false | {
"file_name": "src/MerkleTree.New.High.Correct.Path.fst",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 58,
"end_line": 310,
"start_col": 0,
"start_line": 293
} | module MerkleTree.New.High.Correct.Path
open EverCrypt
open EverCrypt.Helpers
open MerkleTree.New.High.Correct.Base
// Need to use some facts of `mt_get_root`
open MerkleTree.New.High.Correct.Rhs
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module List = FStar.List.Tot
module S = FStar.Seq
module U32 = FStar.UInt32
module U8 = FStar.UInt8
type uint32_t = U32.t
type uint8_t = U8.t
module EHS = EverCrypt.Hash
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#reset-options "--z3rlimit 20"
/// Correctness of path generation
val path_spec:
#hsz:pos ->
k:nat ->
j:nat{k <= j} ->
actd:bool ->
p:path #hsz {S.length p = mt_path_length k j actd} ->
GTot (sp:S.seq (MTS.padded_hash #hsz){S.length sp = log2c j})
(decreases j)
let rec path_spec #hsz k j actd p =
if j = 0 then S.empty
else (if k % 2 = 0
then (if j = k || (j = k + 1 && not actd)
then S.cons MTS.HPad (path_spec (k / 2) (j / 2) (actd || (j % 2 = 1)) p)
else S.cons (MTS.HRaw #hsz (S.head p))
(path_spec (k / 2) (j / 2) (actd || (j % 2 = 1)) (S.tail p)))
else S.cons (MTS.HRaw #hsz (S.head p))
(path_spec (k / 2) (j / 2) (actd || (j % 2 = 1)) (S.tail p)))
val mt_get_path_step_acc:
#hsz:pos ->
j:nat{j > 0} ->
chs:hashes #hsz {S.length chs = j} ->
crh:hash #hsz ->
k:nat{k <= j} ->
actd:bool ->
GTot (option (hash #hsz))
let mt_get_path_step_acc #hsz j chs crh k actd =
if k % 2 = 1
then Some (S.index chs (k - 1))
else (if k = j then None
else if k + 1 = j
then (if actd then Some crh else None)
else Some (S.index chs (k + 1)))
val mt_get_path_acc:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
k:nat{k <= j} ->
actd:bool ->
GTot (np:path #hsz {S.length np = mt_path_length k j actd})
(decreases j)
let rec mt_get_path_acc #_ #f j fhs rhs k actd =
if j = 0 then S.empty
else
(let sp = mt_get_path_step_acc #_ j (S.head fhs) (S.head rhs) k actd in
let rp = mt_get_path_acc #_ #f (j / 2) (S.tail fhs) (S.tail rhs) (k / 2)
(actd || j % 2 = 1) in
if Some? sp
then (S.cons (Some?.v sp) rp)
else rp)
val mt_get_path_step_acc_consistent:
#hsz:pos -> #f:MTS.hash_fun_t ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs i j} ->
rhs:hashes #hsz {S.length rhs = 32} ->
k:nat{i <= k && k <= j} ->
actd:bool ->
Lemma (requires (j <> 0))
(ensures
(log2c_bound j (32 - lv);
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs);
(match mt_get_path_step_acc j
(S.index (merge_hs #_ #f olds hs) lv) (S.index rhs lv)
k actd with
| Some v ->
S.equal (mt_make_path_step lv hs rhs i j k S.empty actd)
(S.cons v S.empty)
| None ->
S.equal (mt_make_path_step lv hs rhs i j k S.empty actd)
S.empty)))
let mt_get_path_step_acc_consistent #_ #_ lv i j olds hs rhs k actd = ()
private val seq_cons_append:
#a:Type -> hd:a -> tl:S.seq a ->
Lemma (S.equal (S.append (S.cons hd S.empty) tl)
(S.cons hd tl))
private let seq_cons_append #a hd tl = ()
val mt_get_path_acc_consistent:
#hsz:pos -> #f:MTS.hash_fun_t ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs i j} ->
rhs:hashes #hsz {S.length rhs = 32} ->
k:nat{i <= k && k <= j} ->
actd:bool ->
Lemma (requires True)
(ensures
(log2c_bound j (32 - lv);
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs);
S.equal (mt_get_path_acc #_ #f j
(S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j))
(S.slice rhs lv (lv + log2c j)) k actd)
(mt_get_path_ #_ lv hs rhs i j k S.empty actd)))
(decreases j)
#push-options "--z3rlimit 1000 --max_fuel 1 --max_ifuel 0"
let rec mt_get_path_acc_consistent #hsz #f lv i j olds hs rhs k actd =
log2c_bound j (32 - lv);
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs);
if j = 0 then ()
else begin
let nactd = if j % 2 = 0 then actd else true in
let nactd_ = actd || j % 2 = 1 in
assert (nactd == nactd_);
let pa = mt_get_path_acc #_ #f j
(S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j))
(S.slice rhs lv (lv + log2c j)) k actd in
let p = mt_get_path_ lv hs rhs i j k S.empty actd in
log2c_div j; log2c_bound (j / 2) (32 - (lv + 1));
assert (mt_hashes_lth_inv (lv + 1) (j / 2) (merge_hs #_ #f olds hs));
assert (mt_hashes_lth_inv_log #hsz (j / 2)
(S.slice (merge_hs #_ #f olds hs) (lv + 1) (lv + 1 + log2c (j / 2))));
let npsa = mt_get_path_step_acc j
(S.index (merge_hs #_ #f olds hs) lv) (S.index rhs lv) k actd in
let npa = mt_get_path_acc #_ #f (j / 2)
(S.slice (merge_hs #_ #f olds hs) (lv + 1) (lv + 1 + log2c (j / 2)))
(S.slice rhs (lv + 1) (lv + 1 + log2c (j / 2))) (k / 2) nactd_ in
let nps = mt_make_path_step lv hs rhs i j k S.empty actd in
let np = mt_get_path_ (lv + 1) hs rhs (i / 2) (j / 2) (k / 2) nps nactd in
let npe = mt_get_path_ (lv + 1) hs rhs (i / 2) (j / 2) (k / 2) S.empty nactd in
mt_get_path_pull (lv + 1) hs rhs (i / 2) (j / 2) (k / 2) nps nactd;
assert (S.equal p np);
assert (S.equal np (S.append nps npe));
assert (S.equal p (S.append nps npe));
assert (S.equal pa (if Some? npsa
then S.cons (Some?.v npsa) npa
else npa));
mt_get_path_acc_consistent #_ #f (lv + 1) (i / 2) (j / 2)
olds hs rhs (k / 2) nactd;
assert (S.equal npa npe);
mt_get_path_step_acc_consistent #_ #f lv i j olds hs rhs k actd;
if Some? npsa
then begin
assert (S.equal nps (S.cons (Some?.v npsa) S.empty));
assert (S.equal p (S.append (S.cons (Some?.v npsa) S.empty) npa));
assert (S.equal pa (S.cons (Some?.v npsa) npa));
seq_cons_append (Some?.v npsa) npa;
assert (S.equal pa p)
end
else begin
assert (S.equal nps S.empty);
S.append_empty_l npe;
assert (S.equal p npe);
assert (S.equal pa npa);
assert (S.equal pa p)
end
end
#pop-options
val mt_get_path_acc_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
k:nat{k <= j} ->
acc:hash -> actd:bool ->
Lemma (requires (j > 0 /\
mt_hashes_lth_inv_log #hsz j fhs /\
mt_hashes_inv_log #_ #f j fhs /\
mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) rhs actd))
(ensures (S.equal (path_spec k j actd (mt_get_path_acc #_ #f j fhs rhs k actd))
(MTS.mt_get_path #_ #f #(log2c j)
(hash_seq_spec_full #_ #f (S.head fhs) acc actd) k)))
(decreases j)
#push-options "--z3rlimit 120 --max_fuel 1"
let rec mt_get_path_acc_inv_ok #_ #f j fhs rhs k acc actd =
// Below dummy `let` is necessary to provide guidance to the SMT solver.
let _ = mt_get_path_step_acc j (S.head fhs) (S.head rhs) k actd in
let smt = hash_seq_spec_full #_ #f (S.head fhs) acc actd in
let nacc = (if j % 2 = 0 then acc
else if actd
then f (S.last (S.head fhs)) acc
else S.last (S.head fhs)) in
let nactd = actd || j % 2 = 1 in
if j = 1 then (if k = 0 then () else ())
else begin
mt_hashes_lth_inv_log_next #_ #f j fhs;
hash_seq_spec_full_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd nacc nactd;
mt_get_path_acc_inv_ok #_ #f (j / 2) (S.tail fhs) (S.tail rhs) (k / 2) nacc nactd;
if k % 2 = 0
then begin
if k = j || (k + 1 = j && not actd)
then assert (S.index smt (k + 1) == MTS.HPad)
else if k + 1 = j
then assert (S.index smt (k + 1) == MTS.HRaw (S.head rhs))
else hash_seq_spec_full_index_raw #_ #f (S.head fhs) acc actd (k + 1)
end
else begin
hash_seq_spec_full_index_raw #_ #f (S.head fhs) acc actd (k - 1)
end
end
#pop-options
#push-options "--max_fuel 1 --initial_fuel 1 --max_ifuel 0 --z3rlimit 60"
val mt_get_path_inv_ok_:
#hsz:pos -> #f:MTS.hash_fun_t ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{j > 0 /\ i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs i j} ->
rhs:hashes #hsz {S.length rhs = 32} ->
k:nat{i <= k && k <= j} ->
p:path #hsz ->
acc:hash -> actd:bool ->
Lemma (requires (log2c_div j; log2c_bound j (32 - lv);
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
(mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs) /\
(let t1 = hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd in
let t2 = S.slice rhs lv (lv + log2c j) in
mt_rhs_inv #_ #f j t1 t2 actd))))
(ensures (S.equal (path_spec k j actd
(S.slice (mt_get_path_ lv hs rhs i j k p actd)
(S.length p) (S.length p + mt_path_length k j actd)))
(MTS.mt_get_path #_ #f #(log2c j)
(hash_seq_spec_full #_ #f
(S.index (merge_hs #_ #f olds hs) lv) acc actd) k)))
let mt_get_path_inv_ok_ #_ #f lv i j olds hs rhs k p acc actd =
log2c_div j; log2c_bound j (32 - lv);
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs);
mt_hashes_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs);
mt_get_path_acc_consistent #_ #f lv i j olds hs rhs k actd;
mt_get_path_slice lv hs rhs i j k p actd;
mt_get_path_acc_inv_ok #_ #f j
(S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j))
(S.slice rhs lv (lv + log2c j))
k acc actd
#pop-options
val mt_get_path_inv_ok:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
idx:nat{MT?.i mt <= idx && idx < MT?.j mt} ->
drt:hash ->
Lemma (requires (MT?.j mt > 0 /\ mt_inv mt olds))
(ensures (let j, p, rt = mt_get_path mt idx drt in
j == MT?.j mt /\
mt_root_inv #_ #(MT?.hash_fun mt) (mt_base mt olds) hash_init false rt /\
S.head p == S.index (mt_base mt olds) idx /\
(assert (S.length (S.tail p) == mt_path_length idx (MT?.j mt) false);
S.equal (path_spec idx (MT?.j mt) false (S.tail p))
(MTS.mt_get_path #_ #(MT?.hash_fun mt) #(log2c j) (mt_spec mt olds) idx)))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.Correct.Rhs.fst.checked",
"MerkleTree.New.High.Correct.Base.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Path.fst"
} | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct.Rhs",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mt: MerkleTree.New.High.merkle_tree{MerkleTree.New.High.mt_wf_elts mt} ->
olds:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length olds = 32 /\
MerkleTree.New.High.Correct.Base.mt_olds_inv 0 (MT?.i mt) olds } ->
idx: Prims.nat{MT?.i mt <= idx && idx < MT?.j mt} ->
drt: MerkleTree.New.High.hash
-> FStar.Pervasives.Lemma
(requires MT?.j mt > 0 /\ MerkleTree.New.High.Correct.Base.mt_inv mt olds)
(ensures
(let _ = MerkleTree.New.High.mt_get_path mt idx drt in
(let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ j p rt = _ in
j == MT?.j mt /\
MerkleTree.New.High.Correct.Base.mt_root_inv (MerkleTree.New.High.Correct.Base.mt_base mt
olds)
MerkleTree.New.High.hash_init
false
rt /\
FStar.Seq.Properties.head p ==
FStar.Seq.Base.index (MerkleTree.New.High.Correct.Base.mt_base mt olds) idx /\
(assert (FStar.Seq.Base.length (FStar.Seq.Properties.tail p) ==
MerkleTree.New.High.mt_path_length idx (MT?.j mt) false);
FStar.Seq.Base.equal (MerkleTree.New.High.Correct.Path.path_spec idx
(MT?.j mt)
false
(FStar.Seq.Properties.tail p))
(MerkleTree.Spec.mt_get_path (MerkleTree.New.High.Correct.Base.mt_spec mt olds) idx)
))
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.pos",
"MerkleTree.New.High.merkle_tree",
"MerkleTree.New.High.mt_wf_elts",
"MerkleTree.New.High.hashess",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.__proj__MT__item__i",
"Prims.nat",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"MerkleTree.New.High.__proj__MT__item__j",
"MerkleTree.New.High.hash",
"MerkleTree.New.High.path",
"Prims.op_Addition",
"MerkleTree.New.High.mt_path_length",
"MerkleTree.New.High.Correct.Path.mt_get_path_inv_ok_",
"MerkleTree.New.High.__proj__MT__item__hash_fun",
"MerkleTree.New.High.__proj__MT__item__hs",
"MerkleTree.New.High.__proj__MT__item__rhs",
"MerkleTree.New.High.hash_init",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Properties.tail",
"FStar.Seq.Properties.head",
"FStar.Seq.Base.index",
"MerkleTree.New.High.Correct.Base.mt_base",
"FStar.Seq.Base.slice",
"MerkleTree.New.High.mt_get_path_unchanged",
"MerkleTree.New.High.path_insert",
"FStar.Seq.Base.empty",
"FStar.Pervasives.Native.tuple2",
"MerkleTree.New.High.mt_get_root",
"MerkleTree.New.High.offset_of",
"MerkleTree.New.High.Correct.Base.mt_root_inv",
"MerkleTree.New.High.Correct.Rhs.mt_get_root_inv_ok",
"FStar.Pervasives.Native.tuple3",
"MerkleTree.New.High.mt_get_path"
] | [] | false | false | true | false | false | let mt_get_path_inv_ok #hsz mt olds idx drt =
| let j, p, rt = mt_get_path mt idx drt in
mt_get_root_inv_ok mt drt olds;
assert (j == MT?.j mt);
assert (mt_root_inv #_ #(MT?.hash_fun mt) (mt_base mt olds) hash_init false rt);
let ofs = offset_of (MT?.i mt) in
let umt, _ = mt_get_root mt drt in
let ip = path_insert S.empty (S.index (mt_base mt olds) idx) in
mt_get_path_unchanged 0 (MT?.hs umt) (MT?.rhs umt) (MT?.i umt) (MT?.j umt) idx ip false;
assert (S.head ip == S.head (S.slice p 0 (S.length ip)));
assert (S.head ip == S.head p);
assert (S.head p == S.index (mt_base mt olds) idx);
assert (S.length (S.tail p) == mt_path_length idx (MT?.j mt) false);
mt_get_path_inv_ok_ #_ #(MT?.hash_fun mt) 0 (MT?.i umt) (MT?.j umt) olds (MT?.hs umt) (MT?.rhs umt)
idx ip hash_init false | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.kem_hash_of_cs | val kem_hash_of_cs (cs: ciphersuite) : hash_algorithm | val kem_hash_of_cs (cs: ciphersuite) : hash_algorithm | let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 58,
"start_col": 0,
"start_line": 57
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Spec.Agile.HPKE.hash_algorithm | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.DH.algorithm",
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.aead",
"Spec.Hash.Definitions.hash_alg"
] | [] | false | false | false | true | false | let kem_hash_of_cs (cs: ciphersuite) : hash_algorithm =
| let _, h, _, _ = cs in
h | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.ciphersuite_not_export_only | val ciphersuite_not_export_only : Type0 | let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs} | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 89,
"end_line": 73,
"start_col": 0,
"start_line": 73
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Prims.b2t",
"Spec.Agile.HPKE.is_valid_not_export_only_ciphersuite"
] | [] | false | false | false | true | true | let ciphersuite_not_export_only =
| cs: ciphersuite{is_valid_not_export_only_ciphersuite cs} | false |
|
Vale.AsLowStar.Wrapper.fsti | Vale.AsLowStar.Wrapper.prediction_pre_rel | val prediction_pre_rel
(#max_arity: nat)
(#arg_reg: IX64.arg_reg_relation max_arity)
(pre: VSig.vale_pre_tl [])
(code: V.va_code)
(args: IX64.arg_list)
: IX64.prediction_pre_rel_t code args | val prediction_pre_rel
(#max_arity: nat)
(#arg_reg: IX64.arg_reg_relation max_arity)
(pre: VSig.vale_pre_tl [])
(code: V.va_code)
(args: IX64.arg_list)
: IX64.prediction_pre_rel_t code args | let prediction_pre_rel
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(pre:VSig.vale_pre_tl [])
(code:V.va_code)
(args:IX64.arg_list)
: IX64.prediction_pre_rel_t code args
=
fun (h0:mem_roots args) ->
LSig.(to_low_pre #max_arity #arg_reg pre args h0) | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 35,
"start_col": 0,
"start_line": 26
} | module Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.Wrapper.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
pre: Vale.AsLowStar.ValeSig.vale_pre_tl [] ->
code: Vale.X64.Decls.va_code ->
args: Vale.Interop.X64.arg_list
-> Vale.Interop.X64.prediction_pre_rel_t code args | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.AsLowStar.ValeSig.vale_pre_tl",
"Prims.Nil",
"Vale.Interop.Base.td",
"Vale.X64.Decls.va_code",
"Vale.Interop.X64.arg_list",
"Vale.Interop.Base.mem_roots",
"Vale.AsLowStar.LowStarSig.to_low_pre",
"Prims.prop",
"Vale.Interop.X64.prediction_pre_rel_t"
] | [] | false | false | false | false | false | let prediction_pre_rel
(#max_arity: nat)
(#arg_reg: IX64.arg_reg_relation max_arity)
(pre: VSig.vale_pre_tl [])
(code: V.va_code)
(args: IX64.arg_list)
: IX64.prediction_pre_rel_t code args =
| fun (h0: mem_roots args) -> let open LSig in to_low_pre #max_arity #arg_reg pre args h0 | false |
Hacl.Chacha20.fst | Hacl.Chacha20.chacha20_encrypt | val chacha20_encrypt:
len:size_t
-> out:lbuffer uint8 len
-> text:lbuffer uint8 len
-> key:lbuffer uint8 32ul
-> n:lbuffer uint8 12ul
-> ctr:size_t ->
Stack unit
(requires fun h ->
live h key /\ live h n /\ live h text /\ live h out /\ eq_or_disjoint text out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == Spec.Chacha20.chacha20_encrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 text)) | val chacha20_encrypt:
len:size_t
-> out:lbuffer uint8 len
-> text:lbuffer uint8 len
-> key:lbuffer uint8 32ul
-> n:lbuffer uint8 12ul
-> ctr:size_t ->
Stack unit
(requires fun h ->
live h key /\ live h n /\ live h text /\ live h out /\ eq_or_disjoint text out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == Spec.Chacha20.chacha20_encrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 text)) | let chacha20_encrypt len out text key n ctr =
Hacl.Impl.Chacha20.chacha20_encrypt len out text key n ctr | {
"file_name": "code/chacha20/Hacl.Chacha20.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 60,
"end_line": 23,
"start_col": 0,
"start_line": 22
} | module Hacl.Chacha20
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
val chacha20_encrypt:
len:size_t
-> out:lbuffer uint8 len
-> text:lbuffer uint8 len
-> key:lbuffer uint8 32ul
-> n:lbuffer uint8 12ul
-> ctr:size_t ->
Stack unit
(requires fun h ->
live h key /\ live h n /\ live h text /\ live h out /\ eq_or_disjoint text out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == Spec.Chacha20.chacha20_encrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 text)) | {
"checked_file": "/",
"dependencies": [
"Spec.Chacha20.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Chacha20.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Chacha20.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Lib.IntTypes.size_t ->
out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len ->
text: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len ->
key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 12ul ->
ctr: Lib.IntTypes.size_t
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Chacha20.chacha20_encrypt",
"Prims.unit"
] | [] | false | true | false | false | false | let chacha20_encrypt len out text key n ctr =
| Hacl.Impl.Chacha20.chacha20_encrypt len out text key n ctr | false |
Vale.AsLowStar.Wrapper.fsti | Vale.AsLowStar.Wrapper.post_rel_generic | val post_rel_generic
(#max_arity: nat)
(code: V.va_code)
(dom: list td)
(args: list arg {List.length dom + List.length args <= 20})
(post: VSig.vale_post_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_post_rel_t (coerce code)) | val post_rel_generic
(#max_arity: nat)
(code: V.va_code)
(dom: list td)
(args: list arg {List.length dom + List.length args <= 20})
(post: VSig.vale_post_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_post_rel_t (coerce code)) | let rec post_rel_generic
(#max_arity:nat)
(code:V.va_code)
(dom:list td)
(args:list arg{List.length dom + List.length args <= 20})
(post:VSig.vale_post_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_post_rel_t (coerce code))
=
match dom with
| [] ->
prediction_post_rel #max_arity post (coerce code) args
| hd::tl ->
fun (x:td_as_type hd) ->
post_rel_generic #max_arity code tl IX64.(x ++ args) (elim_1 post x) | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 72,
"end_line": 110,
"start_col": 0,
"start_line": 97
} | module Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
[@__reduce__]
let prediction_pre_rel
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(pre:VSig.vale_pre_tl [])
(code:V.va_code)
(args:IX64.arg_list)
: IX64.prediction_pre_rel_t code args
=
fun (h0:mem_roots args) ->
LSig.(to_low_pre #max_arity #arg_reg pre args h0)
[@__reduce__]
let prediction_post_rel
(#max_arity:nat)
(post:VSig.vale_post_tl [])
(code:V.va_code)
(args:IX64.arg_list)
: IX64.prediction_post_rel_t code args
=
fun
(h0:mem_roots args)
(_s0:BS.machine_state)
(rax_fuel_mem:(UInt64.t & nat & interop_heap))
(s1:BS.machine_state) ->
let rax, fuel, mem = rax_fuel_mem in
exists h1.
h1 == hs_of_mem mem /\
mem_roots_p h1 args /\
LSig.(to_low_post post args h0 rax h1)
val vale_lemma_as_prediction
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(#regs_modified:MS.reg_64 -> bool)
(#xmms_modified:MS.reg_xmm -> bool)
(code:V.va_code)
(args:IX64.arg_list)
(pre:VSig.vale_pre_tl [])
(post:VSig.vale_post_tl [])
(v:VSig.vale_sig_tl regs_modified xmms_modified args (coerce code) pre post)
: IX64.prediction
max_arity
arg_reg
regs_modified
xmms_modified
(coerce code)
args
(prediction_pre_rel #max_arity #arg_reg pre (coerce code) args)
(prediction_post_rel #max_arity post (coerce code) args)
// ////////////////////////////////////////////////////////////////////////////////
// //Wrap abstract
// ////////////////////////////////////////////////////////////////////////////////
[@__reduce__]
let rec pre_rel_generic
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(code:V.va_code)
(dom:list td)
(args:list arg{List.length dom + List.length args <= 20})
(pre:VSig.vale_pre_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_pre_rel_t (coerce code))
=
match dom with
| [] ->
prediction_pre_rel #max_arity #arg_reg pre (coerce code) args
| hd::tl ->
fun (x:td_as_type hd) ->
pre_rel_generic #max_arity #arg_reg code tl IX64.(x ++ args) (elim_1 pre x) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.Wrapper.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
code: Vale.X64.Decls.va_code ->
dom: Prims.list Vale.Interop.Base.td ->
args:
Prims.list Vale.Interop.Base.arg
{FStar.List.Tot.Base.length dom + FStar.List.Tot.Base.length args <= 20} ->
post: Vale.AsLowStar.ValeSig.vale_post_tl dom
-> Vale.Interop.X64.rel_gen_t code
dom
args
(Vale.Interop.X64.prediction_post_rel_t (Vale.Interop.Base.coerce code)) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.X64.Decls.va_code",
"Prims.list",
"Vale.Interop.Base.td",
"Vale.Interop.Base.arg",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.AsLowStar.ValeSig.vale_post_tl",
"Vale.AsLowStar.Wrapper.prediction_post_rel",
"Vale.Interop.Base.coerce",
"Vale.Interop.Base.td_as_type",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Interop.X64.op_Plus_Plus",
"Vale.Interop.Base.elim_1",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Prims.prop",
"Vale.Interop.X64.rel_gen_t",
"Vale.Interop.X64.prediction_post_rel_t",
"Vale.X64.Machine_Semantics_s.code"
] | [
"recursion"
] | false | false | false | false | false | let rec post_rel_generic
(#max_arity: nat)
(code: V.va_code)
(dom: list td)
(args: list arg {List.length dom + List.length args <= 20})
(post: VSig.vale_post_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_post_rel_t (coerce code)) =
| match dom with
| [] -> prediction_post_rel #max_arity post (coerce code) args
| hd :: tl ->
fun (x: td_as_type hd) -> post_rel_generic #max_arity code tl IX64.(x ++ args) (elim_1 post x) | false |
Vale.AsLowStar.Wrapper.fsti | Vale.AsLowStar.Wrapper.pre_rel_generic | val pre_rel_generic
(#max_arity: nat)
(#arg_reg: IX64.arg_reg_relation max_arity)
(code: V.va_code)
(dom: list td)
(args: list arg {List.length dom + List.length args <= 20})
(pre: VSig.vale_pre_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_pre_rel_t (coerce code)) | val pre_rel_generic
(#max_arity: nat)
(#arg_reg: IX64.arg_reg_relation max_arity)
(code: V.va_code)
(dom: list td)
(args: list arg {List.length dom + List.length args <= 20})
(pre: VSig.vale_pre_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_pre_rel_t (coerce code)) | let rec pre_rel_generic
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(code:V.va_code)
(dom:list td)
(args:list arg{List.length dom + List.length args <= 20})
(pre:VSig.vale_pre_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_pre_rel_t (coerce code))
=
match dom with
| [] ->
prediction_pre_rel #max_arity #arg_reg pre (coerce code) args
| hd::tl ->
fun (x:td_as_type hd) ->
pre_rel_generic #max_arity #arg_reg code tl IX64.(x ++ args) (elim_1 pre x) | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 79,
"end_line": 94,
"start_col": 0,
"start_line": 80
} | module Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
[@__reduce__]
let prediction_pre_rel
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(pre:VSig.vale_pre_tl [])
(code:V.va_code)
(args:IX64.arg_list)
: IX64.prediction_pre_rel_t code args
=
fun (h0:mem_roots args) ->
LSig.(to_low_pre #max_arity #arg_reg pre args h0)
[@__reduce__]
let prediction_post_rel
(#max_arity:nat)
(post:VSig.vale_post_tl [])
(code:V.va_code)
(args:IX64.arg_list)
: IX64.prediction_post_rel_t code args
=
fun
(h0:mem_roots args)
(_s0:BS.machine_state)
(rax_fuel_mem:(UInt64.t & nat & interop_heap))
(s1:BS.machine_state) ->
let rax, fuel, mem = rax_fuel_mem in
exists h1.
h1 == hs_of_mem mem /\
mem_roots_p h1 args /\
LSig.(to_low_post post args h0 rax h1)
val vale_lemma_as_prediction
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(#regs_modified:MS.reg_64 -> bool)
(#xmms_modified:MS.reg_xmm -> bool)
(code:V.va_code)
(args:IX64.arg_list)
(pre:VSig.vale_pre_tl [])
(post:VSig.vale_post_tl [])
(v:VSig.vale_sig_tl regs_modified xmms_modified args (coerce code) pre post)
: IX64.prediction
max_arity
arg_reg
regs_modified
xmms_modified
(coerce code)
args
(prediction_pre_rel #max_arity #arg_reg pre (coerce code) args)
(prediction_post_rel #max_arity post (coerce code) args)
// ////////////////////////////////////////////////////////////////////////////////
// //Wrap abstract
// //////////////////////////////////////////////////////////////////////////////// | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.Wrapper.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
code: Vale.X64.Decls.va_code ->
dom: Prims.list Vale.Interop.Base.td ->
args:
Prims.list Vale.Interop.Base.arg
{FStar.List.Tot.Base.length dom + FStar.List.Tot.Base.length args <= 20} ->
pre: Vale.AsLowStar.ValeSig.vale_pre_tl dom
-> Vale.Interop.X64.rel_gen_t code
dom
args
(Vale.Interop.X64.prediction_pre_rel_t (Vale.Interop.Base.coerce code)) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.X64.Decls.va_code",
"Prims.list",
"Vale.Interop.Base.td",
"Vale.Interop.Base.arg",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.AsLowStar.ValeSig.vale_pre_tl",
"Vale.AsLowStar.Wrapper.prediction_pre_rel",
"Vale.Interop.Base.coerce",
"Vale.Interop.Base.td_as_type",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.op_Plus_Plus",
"Vale.Interop.Base.elim_1",
"Vale.X64.Decls.va_state",
"Prims.prop",
"Vale.Interop.X64.rel_gen_t",
"Vale.Interop.X64.prediction_pre_rel_t",
"Vale.X64.Machine_Semantics_s.code"
] | [
"recursion"
] | false | false | false | false | false | let rec pre_rel_generic
(#max_arity: nat)
(#arg_reg: IX64.arg_reg_relation max_arity)
(code: V.va_code)
(dom: list td)
(args: list arg {List.length dom + List.length args <= 20})
(pre: VSig.vale_pre_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_pre_rel_t (coerce code)) =
| match dom with
| [] -> prediction_pre_rel #max_arity #arg_reg pre (coerce code) args
| hd :: tl ->
fun (x: td_as_type hd) ->
pre_rel_generic #max_arity #arg_reg code tl IX64.(x ++ args) (elim_1 pre x) | false |
Vale.AsLowStar.Wrapper.fsti | Vale.AsLowStar.Wrapper.mk_prediction | val mk_prediction
(#max_arity: nat)
(#arg_reg: IX64.arg_reg_relation max_arity)
(#regs_modified: (MS.reg_64 -> bool))
(#xmms_modified: (MS.reg_xmm -> bool))
(code: V.va_code)
(dom: list td)
(args: list arg {List.length dom + List.length args <= 20})
(#pre: VSig.vale_pre_tl dom)
(#post: VSig.vale_post_tl dom)
(v: VSig.vale_sig_tl regs_modified xmms_modified args (coerce code) pre post)
: IX64.prediction_t max_arity
arg_reg
regs_modified
xmms_modified
(coerce code)
dom
args
(pre_rel_generic #max_arity #arg_reg code dom args pre)
(post_rel_generic #max_arity code dom args post) | val mk_prediction
(#max_arity: nat)
(#arg_reg: IX64.arg_reg_relation max_arity)
(#regs_modified: (MS.reg_64 -> bool))
(#xmms_modified: (MS.reg_xmm -> bool))
(code: V.va_code)
(dom: list td)
(args: list arg {List.length dom + List.length args <= 20})
(#pre: VSig.vale_pre_tl dom)
(#post: VSig.vale_post_tl dom)
(v: VSig.vale_sig_tl regs_modified xmms_modified args (coerce code) pre post)
: IX64.prediction_t max_arity
arg_reg
regs_modified
xmms_modified
(coerce code)
dom
args
(pre_rel_generic #max_arity #arg_reg code dom args pre)
(post_rel_generic #max_arity code dom args post) | let rec mk_prediction
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(#regs_modified:MS.reg_64 -> bool)
(#xmms_modified:MS.reg_xmm -> bool)
(code:V.va_code)
(dom:list td)
(args:list arg{List.length dom + List.length args <= 20})
(#pre:VSig.vale_pre_tl dom)
(#post:VSig.vale_post_tl dom)
(v:VSig.vale_sig_tl regs_modified xmms_modified args (coerce code) pre post)
: IX64.prediction_t
max_arity
arg_reg
regs_modified
xmms_modified
(coerce code)
dom
args
(pre_rel_generic #max_arity #arg_reg code dom args pre)
(post_rel_generic #max_arity code dom args post)
=
let open IX64 in
match dom with
| [] ->
vale_lemma_as_prediction #max_arity #arg_reg _ _ _ _ v
| hd::tl ->
fun (x:td_as_type hd) ->
mk_prediction
#max_arity
#arg_reg
code
tl
(x ++ args)
#(elim_1 pre x)
#(elim_1 post x)
(VSig.elim_vale_sig_cons hd tl args pre post v x) | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 148,
"start_col": 0,
"start_line": 112
} | module Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
[@__reduce__]
let prediction_pre_rel
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(pre:VSig.vale_pre_tl [])
(code:V.va_code)
(args:IX64.arg_list)
: IX64.prediction_pre_rel_t code args
=
fun (h0:mem_roots args) ->
LSig.(to_low_pre #max_arity #arg_reg pre args h0)
[@__reduce__]
let prediction_post_rel
(#max_arity:nat)
(post:VSig.vale_post_tl [])
(code:V.va_code)
(args:IX64.arg_list)
: IX64.prediction_post_rel_t code args
=
fun
(h0:mem_roots args)
(_s0:BS.machine_state)
(rax_fuel_mem:(UInt64.t & nat & interop_heap))
(s1:BS.machine_state) ->
let rax, fuel, mem = rax_fuel_mem in
exists h1.
h1 == hs_of_mem mem /\
mem_roots_p h1 args /\
LSig.(to_low_post post args h0 rax h1)
val vale_lemma_as_prediction
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(#regs_modified:MS.reg_64 -> bool)
(#xmms_modified:MS.reg_xmm -> bool)
(code:V.va_code)
(args:IX64.arg_list)
(pre:VSig.vale_pre_tl [])
(post:VSig.vale_post_tl [])
(v:VSig.vale_sig_tl regs_modified xmms_modified args (coerce code) pre post)
: IX64.prediction
max_arity
arg_reg
regs_modified
xmms_modified
(coerce code)
args
(prediction_pre_rel #max_arity #arg_reg pre (coerce code) args)
(prediction_post_rel #max_arity post (coerce code) args)
// ////////////////////////////////////////////////////////////////////////////////
// //Wrap abstract
// ////////////////////////////////////////////////////////////////////////////////
[@__reduce__]
let rec pre_rel_generic
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(code:V.va_code)
(dom:list td)
(args:list arg{List.length dom + List.length args <= 20})
(pre:VSig.vale_pre_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_pre_rel_t (coerce code))
=
match dom with
| [] ->
prediction_pre_rel #max_arity #arg_reg pre (coerce code) args
| hd::tl ->
fun (x:td_as_type hd) ->
pre_rel_generic #max_arity #arg_reg code tl IX64.(x ++ args) (elim_1 pre x)
[@__reduce__]
let rec post_rel_generic
(#max_arity:nat)
(code:V.va_code)
(dom:list td)
(args:list arg{List.length dom + List.length args <= 20})
(post:VSig.vale_post_tl dom)
: IX64.rel_gen_t code dom args (IX64.prediction_post_rel_t (coerce code))
=
match dom with
| [] ->
prediction_post_rel #max_arity post (coerce code) args
| hd::tl ->
fun (x:td_as_type hd) ->
post_rel_generic #max_arity code tl IX64.(x ++ args) (elim_1 post x) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.Wrapper.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
code: Vale.X64.Decls.va_code ->
dom: Prims.list Vale.Interop.Base.td ->
args:
Prims.list Vale.Interop.Base.arg
{FStar.List.Tot.Base.length dom + FStar.List.Tot.Base.length args <= 20} ->
v:
Vale.AsLowStar.ValeSig.vale_sig_tl regs_modified
xmms_modified
args
(Vale.Interop.Base.coerce code)
pre
post
-> Vale.Interop.X64.prediction_t max_arity
arg_reg
regs_modified
xmms_modified
(Vale.Interop.Base.coerce code)
dom
args
(Vale.AsLowStar.Wrapper.pre_rel_generic code dom args pre)
(Vale.AsLowStar.Wrapper.post_rel_generic code dom args post) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.X64.Machine_s.reg_64",
"Prims.bool",
"Vale.X64.Machine_s.reg_xmm",
"Vale.X64.Decls.va_code",
"Prims.list",
"Vale.Interop.Base.td",
"Vale.Interop.Base.arg",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.AsLowStar.ValeSig.vale_pre_tl",
"Vale.AsLowStar.ValeSig.vale_post_tl",
"Vale.AsLowStar.ValeSig.vale_sig_tl",
"Vale.Interop.Base.coerce",
"Vale.AsLowStar.Wrapper.vale_lemma_as_prediction",
"Vale.Interop.Base.td_as_type",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.op_Plus_Plus",
"Vale.Interop.Base.elim_1",
"Vale.X64.Decls.va_state",
"Prims.prop",
"Vale.X64.Decls.va_fuel",
"Vale.AsLowStar.ValeSig.elim_vale_sig_cons",
"Vale.Interop.X64.prediction_t",
"Vale.X64.Machine_Semantics_s.code",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.AsLowStar.Wrapper.post_rel_generic"
] | [
"recursion"
] | false | false | false | false | false | let rec mk_prediction
(#max_arity: nat)
(#arg_reg: IX64.arg_reg_relation max_arity)
(#regs_modified: (MS.reg_64 -> bool))
(#xmms_modified: (MS.reg_xmm -> bool))
(code: V.va_code)
(dom: list td)
(args: list arg {List.length dom + List.length args <= 20})
(#pre: VSig.vale_pre_tl dom)
(#post: VSig.vale_post_tl dom)
(v: VSig.vale_sig_tl regs_modified xmms_modified args (coerce code) pre post)
: IX64.prediction_t max_arity
arg_reg
regs_modified
xmms_modified
(coerce code)
dom
args
(pre_rel_generic #max_arity #arg_reg code dom args pre)
(post_rel_generic #max_arity code dom args post) =
| let open IX64 in
match dom with
| [] -> vale_lemma_as_prediction #max_arity #arg_reg _ _ _ _ v
| hd :: tl ->
fun (x: td_as_type hd) ->
mk_prediction #max_arity
#arg_reg
code
tl
(x ++ args)
#(elim_1 pre x)
#(elim_1 post x)
(VSig.elim_vale_sig_cons hd tl args pre post v x) | false |
Hacl.Chacha20.fst | Hacl.Chacha20.chacha20_decrypt | val chacha20_decrypt:
len:size_t
-> out:lbuffer uint8 len
-> cipher:lbuffer uint8 len
-> key:lbuffer uint8 32ul
-> n:lbuffer uint8 12ul
-> ctr:size_t ->
Stack unit
(requires fun h ->
live h key /\ live h n /\ live h cipher /\ live h out /\ eq_or_disjoint cipher out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == Spec.Chacha20.chacha20_decrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 cipher)) | val chacha20_decrypt:
len:size_t
-> out:lbuffer uint8 len
-> cipher:lbuffer uint8 len
-> key:lbuffer uint8 32ul
-> n:lbuffer uint8 12ul
-> ctr:size_t ->
Stack unit
(requires fun h ->
live h key /\ live h n /\ live h cipher /\ live h out /\ eq_or_disjoint cipher out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == Spec.Chacha20.chacha20_decrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 cipher)) | let chacha20_decrypt len out cipher key n ctr =
Hacl.Impl.Chacha20.chacha20_decrypt len out cipher key n ctr | {
"file_name": "code/chacha20/Hacl.Chacha20.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 40,
"start_col": 0,
"start_line": 39
} | module Hacl.Chacha20
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
val chacha20_encrypt:
len:size_t
-> out:lbuffer uint8 len
-> text:lbuffer uint8 len
-> key:lbuffer uint8 32ul
-> n:lbuffer uint8 12ul
-> ctr:size_t ->
Stack unit
(requires fun h ->
live h key /\ live h n /\ live h text /\ live h out /\ eq_or_disjoint text out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == Spec.Chacha20.chacha20_encrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 text))
let chacha20_encrypt len out text key n ctr =
Hacl.Impl.Chacha20.chacha20_encrypt len out text key n ctr
val chacha20_decrypt:
len:size_t
-> out:lbuffer uint8 len
-> cipher:lbuffer uint8 len
-> key:lbuffer uint8 32ul
-> n:lbuffer uint8 12ul
-> ctr:size_t ->
Stack unit
(requires fun h ->
live h key /\ live h n /\ live h cipher /\ live h out /\ eq_or_disjoint cipher out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == Spec.Chacha20.chacha20_decrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 cipher)) | {
"checked_file": "/",
"dependencies": [
"Spec.Chacha20.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Chacha20.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Chacha20.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Lib.IntTypes.size_t ->
out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len ->
cipher: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len ->
key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 12ul ->
ctr: Lib.IntTypes.size_t
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Chacha20.chacha20_decrypt",
"Prims.unit"
] | [] | false | true | false | false | false | let chacha20_decrypt len out cipher key n ctr =
| Hacl.Impl.Chacha20.chacha20_decrypt len out cipher key n ctr | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.hash_of_cs | val hash_of_cs (cs: ciphersuite) : hash_algorithm | val hash_of_cs (cs: ciphersuite) : hash_algorithm | let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 66,
"start_col": 0,
"start_line": 65
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Spec.Agile.HPKE.hash_algorithm | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.DH.algorithm",
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.aead",
"Spec.Hash.Definitions.hash_alg"
] | [] | false | false | false | true | false | let hash_of_cs (cs: ciphersuite) : hash_algorithm =
| let _, _, _, h = cs in
h | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.is_valid_not_export_only_ciphersuite | val is_valid_not_export_only_ciphersuite (cs: ciphersuite) : bool | val is_valid_not_export_only_ciphersuite (cs: ciphersuite) : bool | let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 18,
"end_line": 71,
"start_col": 0,
"start_line": 68
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.HPKE.aead_of_cs",
"Spec.Agile.AEAD.alg",
"Prims.bool"
] | [] | false | false | false | true | false | let is_valid_not_export_only_ciphersuite (cs: ciphersuite) : bool =
| match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.aead_alg_of | val aead_alg_of : cs: Spec.Agile.HPKE.ciphersuite_not_export_only -> Spec.Agile.AEAD.alg | let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 77,
"start_col": 0,
"start_line": 76
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs} | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite_not_export_only -> Spec.Agile.AEAD.alg | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite_not_export_only",
"Spec.Agile.HPKE.aead_of_cs",
"Spec.Agile.AEAD.alg"
] | [] | false | false | false | true | false | let aead_alg_of (cs: ciphersuite_not_export_only) =
| match aead_of_cs cs with | Seal alg -> alg | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_version | val label_version:lbytes size_label_version | val label_version:lbytes size_label_version | let label_version : lbytes size_label_version = createL label_version_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 99,
"start_col": 0,
"start_line": 99
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_version | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_version_list"
] | [] | false | false | false | true | false | let label_version:lbytes size_label_version =
| createL label_version_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_version | val size_label_version:size_nat | val size_label_version:size_nat | let size_label_version: size_nat = 7 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 93,
"start_col": 0,
"start_line": 93
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_version:size_nat =
| 7 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_eae_prk | val size_label_eae_prk:size_nat | val size_label_eae_prk:size_nat | let size_label_eae_prk: size_nat = 7 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 104,
"start_col": 0,
"start_line": 104
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_eae_prk:size_nat =
| 7 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_version_list | val label_version_list:l: list uint8 {List.Tot.length l == size_label_version} | val label_version_list:l: list uint8 {List.Tot.length l == size_label_version} | let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 98,
"start_col": 0,
"start_line": 94
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_version} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_version",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_version_list:l: list uint8 {List.Tot.length l == size_label_version} =
| [@@ inline_let ]let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm (List.Tot.length l == size_label_version);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_shared_secret | val label_shared_secret:lbytes size_label_shared_secret | val label_shared_secret:lbytes size_label_shared_secret | let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 92,
"end_line": 143,
"start_col": 0,
"start_line": 143
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_shared_secret | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_shared_secret_list"
] | [] | false | false | false | true | false | let label_shared_secret:lbytes size_label_shared_secret =
| createL label_shared_secret_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_eae_prk | val label_eae_prk:lbytes size_label_eae_prk | val label_eae_prk:lbytes size_label_eae_prk | let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 110,
"start_col": 0,
"start_line": 110
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_eae_prk | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_eae_prk_list"
] | [] | false | false | false | true | false | let label_eae_prk:lbytes size_label_eae_prk =
| createL label_eae_prk_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_KEM | val label_KEM:lbytes size_label_KEM | val label_KEM:lbytes size_label_KEM | let label_KEM : lbytes size_label_KEM = createL label_KEM_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 121,
"start_col": 0,
"start_line": 121
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_KEM | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_KEM_list"
] | [] | false | false | false | true | false | let label_KEM:lbytes size_label_KEM =
| createL label_KEM_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_KEM | val size_label_KEM:size_nat | val size_label_KEM:size_nat | let size_label_KEM: size_nat = 3 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 115,
"start_col": 0,
"start_line": 115
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_KEM:size_nat =
| 3 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_HPKE | val label_HPKE:lbytes size_label_HPKE | val label_HPKE:lbytes size_label_HPKE | let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 132,
"start_col": 0,
"start_line": 132
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_HPKE | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_HPKE_list"
] | [] | false | false | false | true | false | let label_HPKE:lbytes size_label_HPKE =
| createL label_HPKE_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_psk_id_hash | val label_psk_id_hash:lbytes size_label_psk_id_hash | val label_psk_id_hash:lbytes size_label_psk_id_hash | let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 86,
"end_line": 154,
"start_col": 0,
"start_line": 154
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_psk_id_hash | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_psk_id_hash_list"
] | [] | false | false | false | true | false | let label_psk_id_hash:lbytes size_label_psk_id_hash =
| createL label_psk_id_hash_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_info_hash | val label_info_hash:lbytes size_label_info_hash | val label_info_hash:lbytes size_label_info_hash | let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 80,
"end_line": 165,
"start_col": 0,
"start_line": 165
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_info_hash | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_info_hash_list"
] | [] | false | false | false | true | false | let label_info_hash:lbytes size_label_info_hash =
| createL label_info_hash_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_eae_prk_list | val label_eae_prk_list:l: list uint8 {List.Tot.length l == size_label_eae_prk} | val label_eae_prk_list:l: list uint8 {List.Tot.length l == size_label_eae_prk} | let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 109,
"start_col": 0,
"start_line": 105
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_eae_prk} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_eae_prk",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_eae_prk_list:l: list uint8 {List.Tot.length l == size_label_eae_prk} =
| [@@ inline_let ]let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm (List.Tot.length l == size_label_eae_prk);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_KEM_list | val label_KEM_list:l: list uint8 {List.Tot.length l == size_label_KEM} | val label_KEM_list:l: list uint8 {List.Tot.length l == size_label_KEM} | let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 120,
"start_col": 0,
"start_line": 116
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_KEM} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_KEM",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_KEM_list:l: list uint8 {List.Tot.length l == size_label_KEM} =
| [@@ inline_let ]let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm (List.Tot.length l == size_label_KEM);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_HPKE | val size_label_HPKE:size_nat | val size_label_HPKE:size_nat | let size_label_HPKE: size_nat = 4 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 126,
"start_col": 0,
"start_line": 126
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_HPKE:size_nat =
| 4 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_psk_id_hash_list | val label_psk_id_hash_list:l: list uint8 {List.Tot.length l == size_label_psk_id_hash} | val label_psk_id_hash_list:l: list uint8 {List.Tot.length l == size_label_psk_id_hash} | let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 153,
"start_col": 0,
"start_line": 149
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_psk_id_hash} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_psk_id_hash",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_psk_id_hash_list:l: list uint8 {List.Tot.length l == size_label_psk_id_hash} =
| [@@ inline_let ]let l =
[
u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73;
u8 0x68
]
in
assert_norm (List.Tot.length l == size_label_psk_id_hash);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_HPKE_list | val label_HPKE_list:l: list uint8 {List.Tot.length l == size_label_HPKE} | val label_HPKE_list:l: list uint8 {List.Tot.length l == size_label_HPKE} | let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 131,
"start_col": 0,
"start_line": 127
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_HPKE} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_HPKE",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_HPKE_list:l: list uint8 {List.Tot.length l == size_label_HPKE} =
| [@@ inline_let ]let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm (List.Tot.length l == size_label_HPKE);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_shared_secret | val size_label_shared_secret:size_nat | val size_label_shared_secret:size_nat | let size_label_shared_secret: size_nat = 13 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 137,
"start_col": 0,
"start_line": 137
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_shared_secret:size_nat =
| 13 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_psk_id_hash | val size_label_psk_id_hash:size_nat | val size_label_psk_id_hash:size_nat | let size_label_psk_id_hash: size_nat = 11 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 148,
"start_col": 0,
"start_line": 148
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_psk_id_hash:size_nat =
| 11 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_shared_secret_list | val label_shared_secret_list:l: list uint8 {List.Tot.length l == size_label_shared_secret} | val label_shared_secret_list:l: list uint8 {List.Tot.length l == size_label_shared_secret} | let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 142,
"start_col": 0,
"start_line": 138
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_shared_secret} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_shared_secret",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_shared_secret_list:l: list uint8 {List.Tot.length l == size_label_shared_secret} =
| [@@ inline_let ]let l =
[
u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63;
u8 0x72; u8 0x65; u8 0x74
]
in
assert_norm (List.Tot.length l == size_label_shared_secret);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_key | val size_label_key:size_nat | val size_label_key:size_nat | let size_label_key: size_nat = 3 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 181,
"start_col": 0,
"start_line": 181
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_key:size_nat =
| 3 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_key | val label_key:lbytes size_label_key | val label_key:lbytes size_label_key | let label_key : lbytes size_label_key = createL label_key_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 187,
"start_col": 0,
"start_line": 187
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_key | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_key_list"
] | [] | false | false | false | true | false | let label_key:lbytes size_label_key =
| createL label_key_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_secret | val label_secret:lbytes size_label_secret | val label_secret:lbytes size_label_secret | let label_secret : lbytes size_label_secret = createL label_secret_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 71,
"end_line": 176,
"start_col": 0,
"start_line": 176
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_secret | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_secret_list"
] | [] | false | false | false | true | false | let label_secret:lbytes size_label_secret =
| createL label_secret_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_dh_key | val size_dh_key (cs: ciphersuite) : size_nat | val size_dh_key (cs: ciphersuite) : size_nat | let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 279,
"start_col": 0,
"start_line": 279
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.DH.size_key",
"Spec.Agile.HPKE.kem_dh_of_cs",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | true | false | let size_dh_key (cs: ciphersuite) : size_nat =
| DH.size_key (kem_dh_of_cs cs) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_info_hash_list | val label_info_hash_list:l: list uint8 {List.Tot.length l == size_label_info_hash} | val label_info_hash_list:l: list uint8 {List.Tot.length l == size_label_info_hash} | let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 164,
"start_col": 0,
"start_line": 160
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_info_hash} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_info_hash",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_info_hash_list:l: list uint8 {List.Tot.length l == size_label_info_hash} =
| [@@ inline_let ]let l =
[u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68]
in
assert_norm (List.Tot.length l == size_label_info_hash);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_info_hash | val size_label_info_hash:size_nat | val size_label_info_hash:size_nat | let size_label_info_hash: size_nat = 9 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 159,
"start_col": 0,
"start_line": 159
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_info_hash:size_nat =
| 9 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_base_nonce | val size_label_base_nonce:size_nat | val size_label_base_nonce:size_nat | let size_label_base_nonce: size_nat = 10 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 192,
"start_col": 0,
"start_line": 192
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_base_nonce:size_nat =
| 10 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_secret | val size_label_secret:size_nat | val size_label_secret:size_nat | let size_label_secret: size_nat = 6 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 170,
"start_col": 0,
"start_line": 170
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_secret:size_nat =
| 6 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.pow2_125_1 | val pow2_125_1:_: unit{pow2 125 - 1 == 42535295865117307932921825928971026431} | val pow2_125_1:_: unit{pow2 125 - 1 == 42535295865117307932921825928971026431} | let pow2_125_1 : _:unit{pow2 125 - 1 == 42535295865117307932921825928971026431} = assert_norm(pow2 125 - 1 == 42535295865117307932921825928971026431) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 149,
"end_line": 323,
"start_col": 0,
"start_line": 323
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length)
let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit{Prims.pow2 125 - 1 == 42535295865117307932921825928971026431} | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Prims.op_Subtraction",
"Prims.pow2"
] | [] | false | false | false | false | false | let pow2_125_1:_: unit{pow2 125 - 1 == 42535295865117307932921825928971026431} =
| assert_norm (pow2 125 - 1 == 42535295865117307932921825928971026431) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_exp | val label_exp:lbytes size_label_exp | val label_exp:lbytes size_label_exp | let label_exp : lbytes size_label_exp = createL label_exp_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 209,
"start_col": 0,
"start_line": 209
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_exp | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_exp_list"
] | [] | false | false | false | true | false | let label_exp:lbytes size_label_exp =
| createL label_exp_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.pow2_61_1 | val pow2_61_1:_: unit{pow2 61 - 1 == 2305843009213693951} | val pow2_61_1:_: unit{pow2 61 - 1 == 2305843009213693951} | let pow2_61_1 : _:unit{pow2 61 - 1 == 2305843009213693951} = assert_norm(pow2 61 - 1 == 2305843009213693951) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 108,
"end_line": 322,
"start_col": 0,
"start_line": 322
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length)
let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit{Prims.pow2 61 - 1 == 2305843009213693951} | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Prims.op_Subtraction",
"Prims.pow2"
] | [] | false | false | false | false | false | let pow2_61_1:_: unit{pow2 61 - 1 == 2305843009213693951} =
| assert_norm (pow2 61 - 1 == 2305843009213693951) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_key_list | val label_key_list:l: list uint8 {List.Tot.length l == size_label_key} | val label_key_list:l: list uint8 {List.Tot.length l == size_label_key} | let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 186,
"start_col": 0,
"start_line": 182
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_key} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_key",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_key_list:l: list uint8 {List.Tot.length l == size_label_key} =
| [@@ inline_let ]let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm (List.Tot.length l == size_label_key);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.max_length_psk_id | val max_length_psk_id : a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | let max_length_psk_id (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_hpke size_label_psk_id_hash | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 117,
"end_line": 336,
"start_col": 0,
"start_line": 336
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length)
let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length)
let pow2_61_1 : _:unit{pow2 61 - 1 == 2305843009213693951} = assert_norm(pow2 61 - 1 == 2305843009213693951)
let pow2_125_1 : _:unit{pow2 125 - 1 == 42535295865117307932921825928971026431} = assert_norm(pow2 125 - 1 == 42535295865117307932921825928971026431)
let labeled_extract_max_length_ikm (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v(Hash.max_input_length a) - size_label_version - size_suite_id - size_local_label - Spec.Hash.Definitions.block_length a)
let labeled_expand_max_length_info (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v (Hash.max_input_length a) - Spec.Hash.Definitions.hash_length a - 2 - size_label_version - size_suite_id - size_local_label - 1 - Spec.Hash.Definitions.block_length a) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.labeled_extract_max_length_ikm",
"Spec.Agile.HPKE.size_suite_id_hpke",
"Spec.Agile.HPKE.size_label_psk_id_hash",
"FStar.Pervasives.Native.option",
"Prims.int"
] | [] | false | false | false | true | false | let max_length_psk_id (a: hash_algorithm) =
| labeled_extract_max_length_ikm a size_suite_id_hpke size_label_psk_id_hash | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.max_length_psk | val max_length_psk : a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | let max_length_psk (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_hpke size_label_secret | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 109,
"end_line": 335,
"start_col": 0,
"start_line": 335
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length)
let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length)
let pow2_61_1 : _:unit{pow2 61 - 1 == 2305843009213693951} = assert_norm(pow2 61 - 1 == 2305843009213693951)
let pow2_125_1 : _:unit{pow2 125 - 1 == 42535295865117307932921825928971026431} = assert_norm(pow2 125 - 1 == 42535295865117307932921825928971026431)
let labeled_extract_max_length_ikm (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v(Hash.max_input_length a) - size_label_version - size_suite_id - size_local_label - Spec.Hash.Definitions.block_length a)
let labeled_expand_max_length_info (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v (Hash.max_input_length a) - Spec.Hash.Definitions.hash_length a - 2 - size_label_version - size_suite_id - size_local_label - 1 - Spec.Hash.Definitions.block_length a) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.labeled_extract_max_length_ikm",
"Spec.Agile.HPKE.size_suite_id_hpke",
"Spec.Agile.HPKE.size_label_secret",
"FStar.Pervasives.Native.option",
"Prims.int"
] | [] | false | false | false | true | false | let max_length_psk (a: hash_algorithm) =
| labeled_extract_max_length_ikm a size_suite_id_hpke size_label_secret | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.max_length_info | val max_length_info : a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | let max_length_info (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_hpke size_label_info_hash | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 113,
"end_line": 337,
"start_col": 0,
"start_line": 337
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length)
let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length)
let pow2_61_1 : _:unit{pow2 61 - 1 == 2305843009213693951} = assert_norm(pow2 61 - 1 == 2305843009213693951)
let pow2_125_1 : _:unit{pow2 125 - 1 == 42535295865117307932921825928971026431} = assert_norm(pow2 125 - 1 == 42535295865117307932921825928971026431)
let labeled_extract_max_length_ikm (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v(Hash.max_input_length a) - size_label_version - size_suite_id - size_local_label - Spec.Hash.Definitions.block_length a)
let labeled_expand_max_length_info (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v (Hash.max_input_length a) - Spec.Hash.Definitions.hash_length a - 2 - size_label_version - size_suite_id - size_local_label - 1 - Spec.Hash.Definitions.block_length a)
let max_length_psk (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_hpke size_label_secret | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.labeled_extract_max_length_ikm",
"Spec.Agile.HPKE.size_suite_id_hpke",
"Spec.Agile.HPKE.size_label_info_hash",
"FStar.Pervasives.Native.option",
"Prims.int"
] | [] | false | false | false | true | false | let max_length_info (a: hash_algorithm) =
| labeled_extract_max_length_ikm a size_suite_id_hpke size_label_info_hash | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.max_length_exp_ctx | val max_length_exp_ctx : a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | let max_length_exp_ctx (a:hash_algorithm) = labeled_expand_max_length_info a size_suite_id_hpke size_label_sec | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 110,
"end_line": 338,
"start_col": 0,
"start_line": 338
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length)
let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length)
let pow2_61_1 : _:unit{pow2 61 - 1 == 2305843009213693951} = assert_norm(pow2 61 - 1 == 2305843009213693951)
let pow2_125_1 : _:unit{pow2 125 - 1 == 42535295865117307932921825928971026431} = assert_norm(pow2 125 - 1 == 42535295865117307932921825928971026431)
let labeled_extract_max_length_ikm (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v(Hash.max_input_length a) - size_label_version - size_suite_id - size_local_label - Spec.Hash.Definitions.block_length a)
let labeled_expand_max_length_info (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v (Hash.max_input_length a) - Spec.Hash.Definitions.hash_length a - 2 - size_label_version - size_suite_id - size_local_label - 1 - Spec.Hash.Definitions.block_length a)
let max_length_psk (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_hpke size_label_secret
let max_length_psk_id (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_hpke size_label_psk_id_hash | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.labeled_expand_max_length_info",
"Spec.Agile.HPKE.size_suite_id_hpke",
"Spec.Agile.HPKE.size_label_sec",
"FStar.Pervasives.Native.option",
"Prims.int"
] | [] | false | false | false | true | false | let max_length_exp_ctx (a: hash_algorithm) =
| labeled_expand_max_length_info a size_suite_id_hpke size_label_sec | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_sec | val label_sec:lbytes size_label_sec | val label_sec:lbytes size_label_sec | let label_sec : lbytes size_label_sec = createL label_sec_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 220,
"start_col": 0,
"start_line": 220
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_sec | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_sec_list"
] | [] | false | false | false | true | false | let label_sec:lbytes size_label_sec =
| createL label_sec_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_base_nonce | val label_base_nonce:lbytes size_label_base_nonce | val label_base_nonce:lbytes size_label_base_nonce | let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 83,
"end_line": 198,
"start_col": 0,
"start_line": 198
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_base_nonce | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_base_nonce_list"
] | [] | false | false | false | true | false | let label_base_nonce:lbytes size_label_base_nonce =
| createL label_base_nonce_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_base_nonce_list | val label_base_nonce_list:l: list uint8 {List.Tot.length l == size_label_base_nonce} | val label_base_nonce_list:l: list uint8 {List.Tot.length l == size_label_base_nonce} | let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 197,
"start_col": 0,
"start_line": 193
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_base_nonce} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_base_nonce",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_base_nonce_list:l: list uint8 {List.Tot.length l == size_label_base_nonce} =
| [@@ inline_let ]let l =
[u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65]
in
assert_norm (List.Tot.length l == size_label_base_nonce);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_secret_list | val label_secret_list:l: list uint8 {List.Tot.length l == size_label_secret} | val label_secret_list:l: list uint8 {List.Tot.length l == size_label_secret} | let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 175,
"start_col": 0,
"start_line": 171
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_secret} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_secret",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_secret_list:l: list uint8 {List.Tot.length l == size_label_secret} =
| [@@ inline_let ]let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm (List.Tot.length l == size_label_secret);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_sec | val size_label_sec:size_nat | val size_label_sec:size_nat | let size_label_sec: size_nat = 3 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 214,
"start_col": 0,
"start_line": 214
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_sec:size_nat =
| 3 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.max_length_dkp_ikm | val max_length_dkp_ikm : a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | let max_length_dkp_ikm (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_kem size_label_dkp_prk | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 113,
"end_line": 339,
"start_col": 0,
"start_line": 339
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length)
let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length)
let pow2_61_1 : _:unit{pow2 61 - 1 == 2305843009213693951} = assert_norm(pow2 61 - 1 == 2305843009213693951)
let pow2_125_1 : _:unit{pow2 125 - 1 == 42535295865117307932921825928971026431} = assert_norm(pow2 125 - 1 == 42535295865117307932921825928971026431)
let labeled_extract_max_length_ikm (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v(Hash.max_input_length a) - size_label_version - size_suite_id - size_local_label - Spec.Hash.Definitions.block_length a)
let labeled_expand_max_length_info (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v (Hash.max_input_length a) - Spec.Hash.Definitions.hash_length a - 2 - size_label_version - size_suite_id - size_local_label - 1 - Spec.Hash.Definitions.block_length a)
let max_length_psk (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_hpke size_label_secret
let max_length_psk_id (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_hpke size_label_psk_id_hash
let max_length_info (a:hash_algorithm) = labeled_extract_max_length_ikm a size_suite_id_hpke size_label_info_hash | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.HPKE.hash_algorithm -> FStar.Pervasives.Native.option Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.labeled_extract_max_length_ikm",
"Spec.Agile.HPKE.size_suite_id_kem",
"Spec.Agile.HPKE.size_label_dkp_prk",
"FStar.Pervasives.Native.option",
"Prims.int"
] | [] | false | false | false | true | false | let max_length_dkp_ikm (a: hash_algorithm) =
| labeled_extract_max_length_ikm a size_suite_id_kem size_label_dkp_prk | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_candidate | val label_candidate:lbytes size_label_candidate | val label_candidate:lbytes size_label_candidate | let label_candidate : lbytes size_label_candidate = createL label_candidate_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 80,
"end_line": 242,
"start_col": 0,
"start_line": 242
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_candidate | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_candidate_list"
] | [] | false | false | false | true | false | let label_candidate:lbytes size_label_candidate =
| createL label_candidate_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_dkp_prk_list | val label_dkp_prk_list:l: list uint8 {List.Tot.length l == size_label_dkp_prk} | val label_dkp_prk_list:l: list uint8 {List.Tot.length l == size_label_dkp_prk} | let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 230,
"start_col": 0,
"start_line": 226
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_dkp_prk} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_dkp_prk",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_dkp_prk_list:l: list uint8 {List.Tot.length l == size_label_dkp_prk} =
| [@@ inline_let ]let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm (List.Tot.length l == size_label_dkp_prk);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_exp_list | val label_exp_list:l: list uint8 {List.Tot.length l == size_label_exp} | val label_exp_list:l: list uint8 {List.Tot.length l == size_label_exp} | let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 208,
"start_col": 0,
"start_line": 204
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_exp} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_exp",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_exp_list:l: list uint8 {List.Tot.length l == size_label_exp} =
| [@@ inline_let ]let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm (List.Tot.length l == size_label_exp);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_exp | val size_label_exp:size_nat | val size_label_exp:size_nat | let size_label_exp: size_nat = 3 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 203,
"start_col": 0,
"start_line": 203
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_exp:size_nat =
| 3 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_sec_list | val label_sec_list:l: list uint8 {List.Tot.length l == size_label_sec} | val label_sec_list:l: list uint8 {List.Tot.length l == size_label_sec} | let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 219,
"start_col": 0,
"start_line": 215
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_sec} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_sec",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_sec_list:l: list uint8 {List.Tot.length l == size_label_sec} =
| [@@ inline_let ]let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm (List.Tot.length l == size_label_sec);
l | false |
ScalarUnion.fst | ScalarUnion.u32_or_u16_t | val u32_or_u16_t : Type0 | let u32_or_u16_t = typeof u32_or_u16 | {
"file_name": "share/steel/examples/steelc/ScalarUnion.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 36,
"end_line": 28,
"start_col": 0,
"start_line": 28
} | module ScalarUnion
open Steel.ST.Util
open Steel.ST.C.Types
module U32 = FStar.UInt32
module U16 = FStar.UInt16
(** Like structs, unions are labelled by tags to enforce nominality.
For a more detailed explanation see PointStruct2.fst *)
noextract
inline_for_extraction
[@@ norm_field_attr]
let u32_or_u16_fields =
field_description_cons "as_u32" (scalar U32.t) (
field_description_cons "as_u16" (scalar U16.t) (
field_description_nil))
(** Define the union. Like with mk_c_struct, Karamel detects this
definition at extraction type and emits the corresponding typedef. *)
let _ = define_union "ScalarUnion2.u32_or_u16" u32_or_u16_fields
(** The type of (union u32_or_u16) values. *)
noextract inline_for_extraction
let u32_or_u16 = union "ScalarUnion2.u32_or_u16" u32_or_u16_fields | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "ScalarUnion.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Steel.ST.C.Types.Base.typeof",
"Steel.ST.C.Types.Union.union_t0",
"Steel.C.Typestring.string_cons",
"Steel.C.Typestring.cS",
"Steel.C.Typestring.cc",
"Steel.C.Typestring.ca",
"Steel.C.Typestring.cl",
"Steel.C.Typestring.cr",
"Steel.C.Typestring.cU",
"Steel.C.Typestring.cn",
"Steel.C.Typestring.ci",
"Steel.C.Typestring.co",
"Steel.C.Typestring.c2",
"Steel.C.Typestring.cdot",
"Steel.C.Typestring.cu",
"Steel.C.Typestring.c3",
"Steel.C.Typestring.c_",
"Steel.C.Typestring.c1",
"Steel.C.Typestring.c6",
"Steel.C.Typestring.string_nil",
"Steel.ST.C.Types.Fields.field_t_cons",
"Steel.C.Typestring.cs",
"Steel.ST.C.Types.Scalar.scalar_t",
"FStar.UInt32.t",
"FStar.UInt16.t",
"Steel.ST.C.Types.Fields.field_t_nil",
"ScalarUnion.u32_or_u16_fields",
"ScalarUnion.u32_or_u16"
] | [] | false | false | false | true | true | let u32_or_u16_t =
| typeof u32_or_u16 | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_dkp_prk | val label_dkp_prk:lbytes size_label_dkp_prk | val label_dkp_prk:lbytes size_label_dkp_prk | let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 231,
"start_col": 0,
"start_line": 231
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_dkp_prk | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_dkp_prk_list"
] | [] | false | false | false | true | false | let label_dkp_prk:lbytes size_label_dkp_prk =
| createL label_dkp_prk_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_kem_key | val size_kem_key (cs: ciphersuite) : size_nat | val size_kem_key (cs: ciphersuite) : size_nat | let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 82,
"end_line": 295,
"start_col": 0,
"start_line": 295
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Hash.Definitions.hash_length",
"Spec.Agile.HPKE.kem_hash_of_cs",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | true | false | let size_kem_key (cs: ciphersuite) : size_nat =
| Hash.hash_length (kem_hash_of_cs cs) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_aead_nonce | val size_aead_nonce (cs: ciphersuite) : size_nat | val size_aead_nonce (cs: ciphersuite) : size_nat | let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 264,
"start_col": 0,
"start_line": 260
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
/// | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.HPKE.aead_of_cs",
"Spec.Agile.AEAD.alg",
"Lib.IntTypes.size_nat",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"Prims.pow2"
] | [] | false | false | false | true | false | let size_aead_nonce (cs: ciphersuite) : size_nat =
| assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_candidate | val size_label_candidate:size_nat | val size_label_candidate:size_nat | let size_label_candidate: size_nat = 9 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 236,
"start_col": 0,
"start_line": 236
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_candidate:size_nat =
| 9 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_sk | val size_label_sk:size_nat | val size_label_sk:size_nat | let size_label_sk: size_nat = 2 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 247,
"start_col": 0,
"start_line": 247
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_sk:size_nat =
| 2 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_dh_serialized | val size_dh_serialized (cs: ciphersuite) : size_nat | val size_dh_serialized (cs: ciphersuite) : size_nat | let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 289,
"start_col": 0,
"start_line": 287
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.HPKE.kem_dh_of_cs",
"Spec.Agile.DH.size_public",
"Spec.Agile.DH.DH_Curve25519",
"Spec.Agile.DH.DH_P256",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | true | false | let size_dh_serialized (cs: ciphersuite) : size_nat =
| match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 | false |
CDDLExtractionTest.Choice.fst | CDDLExtractionTest.Choice.impl_mytype | val impl_mytype : CDDL.Pulse.impl_typ (CDDL.Spec.t_choice CDDL.Spec.bytes CDDL.Spec.uint) | let impl_mytype = impl_bytes () `impl_t_choice_none` impl_uint () | {
"file_name": "share/steel/examples/pulse/dice/cbor/CDDLExtractionTest.Choice.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 65,
"end_line": 24,
"start_col": 0,
"start_line": 24
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module CDDLExtractionTest.Choice
open CBOR.Spec
open CDDL.Spec
open CBOR.Pulse
open CDDL.Pulse | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"CDDL.Spec.fsti.checked",
"CDDL.Pulse.fst.checked",
"CBOR.Spec.fsti.checked",
"CBOR.Pulse.fst.checked"
],
"interface_file": false,
"source_file": "CDDLExtractionTest.Choice.fst"
} | [
{
"abbrev": false,
"full_module": "CDDL.Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "CBOR.Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "CDDL.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "CBOR.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "CDDLExtractionTest",
"short_module": null
},
{
"abbrev": false,
"full_module": "CDDLExtractionTest",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | CDDL.Pulse.impl_typ (CDDL.Spec.t_choice CDDL.Spec.bytes CDDL.Spec.uint) | Prims.Tot | [
"total"
] | [] | [
"CDDL.Pulse.impl_t_choice_none",
"CDDL.Spec.bytes",
"CDDL.Spec.uint",
"CDDL.Pulse.impl_bytes",
"CDDL.Pulse.impl_uint"
] | [] | false | false | false | true | false | let impl_mytype =
| (impl_bytes ()) `impl_t_choice_none` (impl_uint ()) | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_candidate_list | val label_candidate_list:l: list uint8 {List.Tot.length l == size_label_candidate} | val label_candidate_list:l: list uint8 {List.Tot.length l == size_label_candidate} | let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 241,
"start_col": 0,
"start_line": 237
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_candidate} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_candidate",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_candidate_list:l: list uint8 {List.Tot.length l == size_label_candidate} =
| [@@ inline_let ]let l =
[u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65]
in
assert_norm (List.Tot.length l == size_label_candidate);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_dh_public | val size_dh_public (cs: ciphersuite) : size_nat | val size_dh_public (cs: ciphersuite) : size_nat | let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 284,
"start_col": 0,
"start_line": 282
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.HPKE.kem_dh_of_cs",
"Spec.Agile.DH.size_public",
"Spec.Agile.DH.DH_Curve25519",
"Prims.op_Addition",
"Spec.Agile.DH.DH_P256",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | true | false | let size_dh_public (cs: ciphersuite) : size_nat =
| match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_label_dkp_prk | val size_label_dkp_prk:size_nat | val size_label_dkp_prk:size_nat | let size_label_dkp_prk: size_nat = 7 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 225,
"start_col": 0,
"start_line": 225
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_label_dkp_prk:size_nat =
| 7 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_kem_kdf | val size_kem_kdf (cs: ciphersuite) : size_nat | val size_kem_kdf (cs: ciphersuite) : size_nat | let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 82,
"end_line": 292,
"start_col": 0,
"start_line": 292
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Hash.Definitions.hash_length",
"Spec.Agile.HPKE.kem_hash_of_cs",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | true | false | let size_kem_kdf (cs: ciphersuite) : size_nat =
| Hash.hash_length (kem_hash_of_cs cs) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.max_seq | val max_seq (cs: ciphersuite) : nat | val max_seq (cs: ciphersuite) : nat | let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 303,
"start_col": 0,
"start_line": 300
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.HPKE.aead_of_cs",
"Spec.Agile.AEAD.alg",
"Prims.op_Subtraction",
"Prims.pow2",
"FStar.Mul.op_Star",
"Spec.Agile.HPKE.size_aead_nonce",
"Prims.nat"
] | [] | false | false | false | true | false | let max_seq (cs: ciphersuite) : nat =
| match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8 * (size_aead_nonce cs)) - 1 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_sk_list | val label_sk_list:l: list uint8 {List.Tot.length l == size_label_sk} | val label_sk_list:l: list uint8 {List.Tot.length l == size_label_sk} | let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 252,
"start_col": 0,
"start_line": 248
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length l == Spec.Agile.HPKE.size_label_sk} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.size_label_sk",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u8",
"Prims.Nil"
] | [] | false | false | false | false | false | let label_sk_list:l: list uint8 {List.Tot.length l == size_label_sk} =
| [@@ inline_let ]let l = [u8 0x73; u8 0x6b] in
assert_norm (List.Tot.length l == size_label_sk);
l | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.label_sk | val label_sk:lbytes size_label_sk | val label_sk:lbytes size_label_sk | let label_sk : lbytes size_label_sk = createL label_sk_list | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 253,
"start_col": 0,
"start_line": 253
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk); | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
Spec.Agile.HPKE.size_label_sk | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.createL",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.HPKE.label_sk_list"
] | [] | false | false | false | true | false | let label_sk:lbytes size_label_sk =
| createL label_sk_list | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_aead_key | val size_aead_key (cs: ciphersuite) : size_nat | val size_aead_key (cs: ciphersuite) : size_nat | let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 270,
"start_col": 0,
"start_line": 267
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.HPKE.aead_of_cs",
"Spec.Agile.AEAD.alg",
"Spec.Agile.AEAD.key_length",
"Spec.Agile.HPKE.aead_alg_of",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | true | false | let size_aead_key (cs: ciphersuite) : size_nat =
| match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.labeled_extract_ikm_length_pred | val labeled_extract_ikm_length_pred : a: Spec.Agile.HPKE.hash_algorithm -> ikm_length: Prims.nat -> Prims.bool | let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 317,
"start_col": 0,
"start_line": 316
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.HPKE.hash_algorithm -> ikm_length: Prims.nat -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.hash_algorithm",
"Prims.nat",
"Spec.Agile.HKDF.extract_ikm_length_pred",
"Prims.op_Addition",
"Spec.Agile.HPKE.size_label_version",
"Prims.bool"
] | [] | false | false | false | true | false | let labeled_extract_ikm_length_pred (a: hash_algorithm) (ikm_length: nat) =
| HKDF.extract_ikm_length_pred a (size_label_version + ikm_length) | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_aead_tag | val size_aead_tag (cs: ciphersuite) : size_nat | val size_aead_tag (cs: ciphersuite) : size_nat | let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 276,
"start_col": 0,
"start_line": 273
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Agile.HPKE.aead_of_cs",
"Spec.Agile.AEAD.alg",
"Spec.Agile.AEAD.tag_length",
"Spec.Agile.HPKE.aead_alg_of",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | true | false | let size_aead_tag (cs: ciphersuite) : size_nat =
| match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_suite_id_kem | val size_suite_id_kem:size_nat | val size_suite_id_kem:size_nat | let size_suite_id_kem: size_nat = size_label_KEM + 2 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 306,
"start_col": 0,
"start_line": 306
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [
"Prims.op_Addition",
"Spec.Agile.HPKE.size_label_KEM"
] | [] | false | false | false | false | false | let size_suite_id_kem:size_nat =
| size_label_KEM + 2 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.labeled_extract_max_length_ikm | val labeled_extract_max_length_ikm : a: Spec.Agile.HPKE.hash_algorithm ->
size_suite_id: Lib.IntTypes.size_nat ->
size_local_label: Lib.IntTypes.size_nat
-> FStar.Pervasives.Native.option Prims.int | let labeled_extract_max_length_ikm (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v(Hash.max_input_length a) - size_label_version - size_suite_id - size_local_label - Spec.Hash.Definitions.block_length a) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 143,
"end_line": 328,
"start_col": 0,
"start_line": 325
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length)
let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length)
let pow2_61_1 : _:unit{pow2 61 - 1 == 2305843009213693951} = assert_norm(pow2 61 - 1 == 2305843009213693951)
let pow2_125_1 : _:unit{pow2 125 - 1 == 42535295865117307932921825928971026431} = assert_norm(pow2 125 - 1 == 42535295865117307932921825928971026431) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Agile.HPKE.hash_algorithm ->
size_suite_id: Lib.IntTypes.size_nat ->
size_local_label: Lib.IntTypes.size_nat
-> FStar.Pervasives.Native.option Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.hash_algorithm",
"Lib.IntTypes.size_nat",
"FStar.Pervasives.Native.None",
"Prims.int",
"Spec.Hash.Definitions.hash_alg",
"FStar.Pervasives.Native.Some",
"Prims.op_Subtraction",
"FStar.Pervasives.Native.__proj__Some__item__v",
"Prims.pos",
"Spec.Hash.Definitions.max_input_length",
"Spec.Agile.HPKE.size_label_version",
"Spec.Hash.Definitions.block_length",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let labeled_extract_max_length_ikm (a: hash_algorithm) (size_suite_id size_local_label: size_nat) =
| match a with
| Hash.SHA3_256 -> None
| _ ->
Some
(Some?.v (Hash.max_input_length a) - size_label_version - size_suite_id - size_local_label -
Spec.Hash.Definitions.block_length a) | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_kdf | val size_kdf (cs: ciphersuite) : size_nat | val size_kdf (cs: ciphersuite) : size_nat | let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 298,
"start_col": 0,
"start_line": 298
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Spec.Hash.Definitions.hash_length",
"Spec.Agile.HPKE.hash_of_cs",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | true | false | let size_kdf (cs: ciphersuite) : size_nat =
| Hash.hash_length (hash_of_cs cs) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_ks_ctx | val size_ks_ctx (cs: ciphersuite) : size_nat | val size_ks_ctx (cs: ciphersuite) : size_nat | let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 83,
"end_line": 314,
"start_col": 0,
"start_line": 314
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | cs: Spec.Agile.HPKE.ciphersuite -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite",
"Prims.op_Addition",
"Spec.Agile.HPKE.size_mode_identifier",
"FStar.Mul.op_Star",
"Spec.Agile.HPKE.size_kdf",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | true | false | let size_ks_ctx (cs: ciphersuite) : size_nat =
| size_mode_identifier + 2 * (size_kdf cs) | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_mode_identifier | val size_mode_identifier:size_nat | val size_mode_identifier:size_nat | let size_mode_identifier: size_nat = 1 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 312,
"start_col": 0,
"start_line": 312
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | false | false | let size_mode_identifier:size_nat =
| 1 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.labeled_expand_info_length_pred | val labeled_expand_info_length_pred : a: Spec.Agile.HPKE.hash_algorithm -> info_length: Prims.nat -> Prims.bool | let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 71,
"end_line": 320,
"start_col": 0,
"start_line": 319
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.HPKE.hash_algorithm -> info_length: Prims.nat -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.hash_algorithm",
"Prims.nat",
"Spec.Agile.HKDF.expand_info_length_pred",
"Prims.op_Addition",
"Spec.Agile.HPKE.size_label_version",
"Prims.bool"
] | [] | false | false | false | true | false | let labeled_expand_info_length_pred (a: hash_algorithm) (info_length: nat) =
| HKDF.expand_info_length_pred a (2 + size_label_version + info_length) | false |
|
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.size_suite_id_hpke | val size_suite_id_hpke:size_nat | val size_suite_id_hpke:size_nat | let size_suite_id_hpke: size_nat = size_label_HPKE + 6 | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 309,
"start_col": 0,
"start_line": 309
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
] | [] | [
"Prims.op_Addition",
"Spec.Agile.HPKE.size_label_HPKE"
] | [] | false | false | false | false | false | let size_suite_id_hpke:size_nat =
| size_label_HPKE + 6 | false |
Spec.Agile.HPKE.fsti | Spec.Agile.HPKE.labeled_expand_max_length_info | val labeled_expand_max_length_info : a: Spec.Agile.HPKE.hash_algorithm ->
size_suite_id: Lib.IntTypes.size_nat ->
size_local_label: Lib.IntTypes.size_nat
-> FStar.Pervasives.Native.option Prims.int | let labeled_expand_max_length_info (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v (Hash.max_input_length a) - Spec.Hash.Definitions.hash_length a - 2 - size_label_version - size_suite_id - size_local_label - 1 - Spec.Hash.Definitions.block_length a) | {
"file_name": "specs/Spec.Agile.HPKE.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 190,
"end_line": 333,
"start_col": 0,
"start_line": 330
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
type mode =
| Base
| PSK
| Auth
| AuthPSK
let is_valid_kem = function
| DH.DH_Curve25519, Hash.SHA2_256
| DH.DH_P256, Hash.SHA2_256 -> true
| _,_ -> false
noeq type aead =
| Seal: alg:AEAD.alg -> aead
| ExportOnly
let is_valid_aead = function
| Seal AEAD.AES128_GCM
| Seal AEAD.AES256_GCM
| Seal AEAD.CHACHA20_POLY1305
| ExportOnly -> true
| _ -> false
let is_valid_hash = function
| Hash.SHA2_256
| Hash.SHA2_384
| Hash.SHA2_512 -> true
| _ -> false
let hash_algorithm = a:Hash.hash_alg{is_valid_hash a}
let is_valid_ciphersuite (cs:DH.algorithm & hash_algorithm & aead & Hash.hash_alg) : bool =
let kem_dh, kem_hash, aead, hash = cs in
(is_valid_kem (kem_dh, kem_hash)) && (is_valid_aead aead) && (is_valid_hash hash)
let ciphersuite = cs:(DH.algorithm & hash_algorithm & aead & Hash.hash_alg){is_valid_ciphersuite cs}
inline_for_extraction
let kem_dh_of_cs (cs:ciphersuite) : DH.algorithm =
let (c,_,_,_) = cs in c
inline_for_extraction
let kem_hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,h,_,_) = cs in h
inline_for_extraction
let aead_of_cs (cs:ciphersuite) : aead =
let (_,_,a,_) = cs in a
inline_for_extraction
let hash_of_cs (cs:ciphersuite) : hash_algorithm =
let (_,_,_,h) = cs in h
let is_valid_not_export_only_ciphersuite (cs:ciphersuite) : bool =
match aead_of_cs cs with
| ExportOnly -> false
| Seal _ -> true
let ciphersuite_not_export_only = cs:ciphersuite{is_valid_not_export_only_ciphersuite cs}
inline_for_extraction
let aead_alg_of (cs:ciphersuite_not_export_only) = match aead_of_cs cs with
| Seal alg -> alg
/// Constants for HPKE labels
///
/// The code for the following constants was generated
/// with the script make_hpke_constants.py. Ultimately,
/// this should be rewritten in Meta-F*. The idea is to
/// write a tactic `mk_label` that inspects a string
/// character by character, and generates the proper
/// definition. It could be used as follows:
/// %splice [label_version] (mk_label "HPKE-v1")
/// Inspiration can be taken from Test.Lowstarize.fst.
// generated: "HPKE-v1"
inline_for_extraction
let size_label_version: size_nat = 7
let label_version_list : l:list uint8{List.Tot.length l == size_label_version} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45; u8 0x2d; u8 0x76; u8 0x31] in
assert_norm(List.Tot.length l == size_label_version);
l
let label_version : lbytes size_label_version = createL label_version_list
// generated: "eae_prk"
inline_for_extraction
let size_label_eae_prk: size_nat = 7
let label_eae_prk_list : l:list uint8{List.Tot.length l == size_label_eae_prk} =
[@inline_let]
let l = [u8 0x65; u8 0x61; u8 0x65; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_eae_prk);
l
let label_eae_prk : lbytes size_label_eae_prk = createL label_eae_prk_list
// generated: "KEM"
inline_for_extraction
let size_label_KEM: size_nat = 3
let label_KEM_list : l:list uint8{List.Tot.length l == size_label_KEM} =
[@inline_let]
let l = [u8 0x4b; u8 0x45; u8 0x4d] in
assert_norm(List.Tot.length l == size_label_KEM);
l
let label_KEM : lbytes size_label_KEM = createL label_KEM_list
// generated: "HPKE"
inline_for_extraction
let size_label_HPKE: size_nat = 4
let label_HPKE_list : l:list uint8{List.Tot.length l == size_label_HPKE} =
[@inline_let]
let l = [u8 0x48; u8 0x50; u8 0x4b; u8 0x45] in
assert_norm(List.Tot.length l == size_label_HPKE);
l
let label_HPKE : lbytes size_label_HPKE = createL label_HPKE_list
// generated: "shared_secret"
inline_for_extraction
let size_label_shared_secret: size_nat = 13
let label_shared_secret_list : l:list uint8{List.Tot.length l == size_label_shared_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x68; u8 0x61; u8 0x72; u8 0x65; u8 0x64; u8 0x5f; u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_shared_secret);
l
let label_shared_secret : lbytes size_label_shared_secret = createL label_shared_secret_list
// generated: "psk_id_hash"
inline_for_extraction
let size_label_psk_id_hash: size_nat = 11
let label_psk_id_hash_list : l:list uint8{List.Tot.length l == size_label_psk_id_hash} =
[@inline_let]
let l = [u8 0x70; u8 0x73; u8 0x6b; u8 0x5f; u8 0x69; u8 0x64; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_psk_id_hash);
l
let label_psk_id_hash : lbytes size_label_psk_id_hash = createL label_psk_id_hash_list
// generated: "info_hash"
inline_for_extraction
let size_label_info_hash: size_nat = 9
let label_info_hash_list : l:list uint8{List.Tot.length l == size_label_info_hash} =
[@inline_let]
let l = [u8 0x69; u8 0x6e; u8 0x66; u8 0x6f; u8 0x5f; u8 0x68; u8 0x61; u8 0x73; u8 0x68] in
assert_norm(List.Tot.length l == size_label_info_hash);
l
let label_info_hash : lbytes size_label_info_hash = createL label_info_hash_list
// generated: "secret"
inline_for_extraction
let size_label_secret: size_nat = 6
let label_secret_list : l:list uint8{List.Tot.length l == size_label_secret} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63; u8 0x72; u8 0x65; u8 0x74] in
assert_norm(List.Tot.length l == size_label_secret);
l
let label_secret : lbytes size_label_secret = createL label_secret_list
// generated: "key"
inline_for_extraction
let size_label_key: size_nat = 3
let label_key_list : l:list uint8{List.Tot.length l == size_label_key} =
[@inline_let]
let l = [u8 0x6b; u8 0x65; u8 0x79] in
assert_norm(List.Tot.length l == size_label_key);
l
let label_key : lbytes size_label_key = createL label_key_list
// generated: "base_nonce"
inline_for_extraction
let size_label_base_nonce: size_nat = 10
let label_base_nonce_list : l:list uint8{List.Tot.length l == size_label_base_nonce} =
[@inline_let]
let l = [u8 0x62; u8 0x61; u8 0x73; u8 0x65; u8 0x5f; u8 0x6e; u8 0x6f; u8 0x6e; u8 0x63; u8 0x65] in
assert_norm(List.Tot.length l == size_label_base_nonce);
l
let label_base_nonce : lbytes size_label_base_nonce = createL label_base_nonce_list
// generated: "exp"
inline_for_extraction
let size_label_exp: size_nat = 3
let label_exp_list : l:list uint8{List.Tot.length l == size_label_exp} =
[@inline_let]
let l = [u8 0x65; u8 0x78; u8 0x70] in
assert_norm(List.Tot.length l == size_label_exp);
l
let label_exp : lbytes size_label_exp = createL label_exp_list
// generated: "sec"
inline_for_extraction
let size_label_sec: size_nat = 3
let label_sec_list : l:list uint8{List.Tot.length l == size_label_sec} =
[@inline_let]
let l = [u8 0x73; u8 0x65; u8 0x63] in
assert_norm(List.Tot.length l == size_label_sec);
l
let label_sec : lbytes size_label_sec = createL label_sec_list
// generated: "dkp_prk"
inline_for_extraction
let size_label_dkp_prk: size_nat = 7
let label_dkp_prk_list : l:list uint8{List.Tot.length l == size_label_dkp_prk} =
[@inline_let]
let l = [u8 0x64; u8 0x6b; u8 0x70; u8 0x5f; u8 0x70; u8 0x72; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_dkp_prk);
l
let label_dkp_prk : lbytes size_label_dkp_prk = createL label_dkp_prk_list
// generated: "candidate"
inline_for_extraction
let size_label_candidate: size_nat = 9
let label_candidate_list : l:list uint8{List.Tot.length l == size_label_candidate} =
[@inline_let]
let l = [u8 0x63; u8 0x61; u8 0x6e; u8 0x64; u8 0x69; u8 0x64; u8 0x61; u8 0x74; u8 0x65] in
assert_norm(List.Tot.length l == size_label_candidate);
l
let label_candidate : lbytes size_label_candidate = createL label_candidate_list
// generated: "sk"
inline_for_extraction
let size_label_sk: size_nat = 2
let label_sk_list : l:list uint8{List.Tot.length l == size_label_sk} =
[@inline_let]
let l = [u8 0x73; u8 0x6b] in
assert_norm(List.Tot.length l == size_label_sk);
l
let label_sk : lbytes size_label_sk = createL label_sk_list
///
/// Constants sizes
///
inline_for_extraction
let size_aead_nonce (cs:ciphersuite): size_nat =
assert_norm (8 * 12 <= pow2 64 - 1);
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> 12
inline_for_extraction
let size_aead_key (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.key_length (aead_alg_of cs)
inline_for_extraction
let size_aead_tag (cs:ciphersuite): size_nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> AEAD.tag_length (aead_alg_of cs)
inline_for_extraction
let size_dh_key (cs:ciphersuite): size_nat = DH.size_key (kem_dh_of_cs cs)
inline_for_extraction
let size_dh_public (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256 + 1 // Need the additional byte for representation
inline_for_extraction
let size_dh_serialized (cs:ciphersuite): size_nat = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> DH.size_public DH.DH_Curve25519
| DH.DH_P256 -> DH.size_public DH.DH_P256
inline_for_extraction
let size_kem_kdf (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kem_key (cs:ciphersuite): size_nat = Hash.hash_length (kem_hash_of_cs cs)
inline_for_extraction
let size_kdf (cs:ciphersuite): size_nat = Hash.hash_length (hash_of_cs cs)
let max_seq (cs:ciphersuite): nat =
match aead_of_cs cs with
| ExportOnly -> 0
| Seal _ -> pow2 (8*(size_aead_nonce cs)) - 1
inline_for_extraction
let size_suite_id_kem: size_nat = size_label_KEM + 2
inline_for_extraction
let size_suite_id_hpke: size_nat = size_label_HPKE + 6
inline_for_extraction
let size_mode_identifier: size_nat = 1
let size_ks_ctx (cs:ciphersuite): size_nat = size_mode_identifier + 2*(size_kdf cs)
let labeled_extract_ikm_length_pred (a:hash_algorithm) (ikm_length:nat) =
HKDF.extract_ikm_length_pred a (size_label_version + ikm_length)
let labeled_expand_info_length_pred (a:hash_algorithm) (info_length:nat) =
HKDF.expand_info_length_pred a (2 + size_label_version + info_length)
let pow2_61_1 : _:unit{pow2 61 - 1 == 2305843009213693951} = assert_norm(pow2 61 - 1 == 2305843009213693951)
let pow2_125_1 : _:unit{pow2 125 - 1 == 42535295865117307932921825928971026431} = assert_norm(pow2 125 - 1 == 42535295865117307932921825928971026431)
let labeled_extract_max_length_ikm (a:hash_algorithm) (size_suite_id:size_nat) (size_local_label:size_nat) =
match a with
| Hash.SHA3_256 -> None
| _ -> Some (Some?.v(Hash.max_input_length a) - size_label_version - size_suite_id - size_local_label - Spec.Hash.Definitions.block_length a) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.HPKE.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"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.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Agile.HPKE.hash_algorithm ->
size_suite_id: Lib.IntTypes.size_nat ->
size_local_label: Lib.IntTypes.size_nat
-> FStar.Pervasives.Native.option Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.hash_algorithm",
"Lib.IntTypes.size_nat",
"FStar.Pervasives.Native.None",
"Prims.int",
"Spec.Hash.Definitions.hash_alg",
"FStar.Pervasives.Native.Some",
"Prims.op_Subtraction",
"FStar.Pervasives.Native.__proj__Some__item__v",
"Prims.pos",
"Spec.Hash.Definitions.max_input_length",
"Spec.Hash.Definitions.hash_length",
"Spec.Agile.HPKE.size_label_version",
"Spec.Hash.Definitions.block_length",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let labeled_expand_max_length_info (a: hash_algorithm) (size_suite_id size_local_label: size_nat) =
| match a with
| Hash.SHA3_256 -> None
| _ ->
Some
(Some?.v (Hash.max_input_length a) - Spec.Hash.Definitions.hash_length a - 2 - size_label_version -
size_suite_id -
size_local_label -
1 -
Spec.Hash.Definitions.block_length a) | false |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.