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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.to_blake_alg | val to_blake_alg : a: Spec.Hash.Definitions.blake_alg -> Spec.Blake2.Definitions.alg | let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 86,
"start_col": 0,
"start_line": 84
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) } | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.blake_alg -> Spec.Blake2.Definitions.alg | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.blake_alg",
"Spec.Blake2.Definitions.Blake2S",
"Spec.Blake2.Definitions.Blake2B",
"Spec.Blake2.Definitions.alg"
] | [] | false | false | false | true | false | let to_blake_alg (a: blake_alg) =
| match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.init_t | val init_t : a: Spec.Hash.Definitions.hash_alg -> Type0 | let init_t (a: hash_alg) = words_state a | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 331,
"start_col": 0,
"start_line": 331
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8
(* Input data, multiple of a block length. *)
let bytes_block a =
l:bytes { Seq.length l = block_length a }
(* Input data, multiple of a block length. *)
let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 }
let output_length = function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512
| Blake2S
| Blake2B -> unit
let hash_length' a (l: output_length a): Lib.IntTypes.size_nat =
if is_shake a then l else hash_length a
(* Output data, i.e. the final hash (tag). *)
let bytes_hash a =
b:bytes { Seq.length b = hash_length a }
let bytes_hash' a l =
b:bytes { Seq.length b = hash_length' a l }
(** The types for the core functions *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.words_state"
] | [] | false | false | false | true | true | let init_t (a: hash_alg) =
| words_state a | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.word_t | val word_t: hash_alg -> Tot inttype | val word_t: hash_alg -> Tot inttype | let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 174,
"start_col": 0,
"start_line": 168
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | _: Spec.Hash.Definitions.hash_alg -> Lib.IntTypes.inttype | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.inttype"
] | [] | false | false | false | true | false | let word_t: hash_alg -> Tot inttype =
| function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64 | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.word_length | val word_length: hash_alg -> Tot nat | val word_length: hash_alg -> Tot nat | let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 194,
"start_col": 0,
"start_line": 188
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | _: Spec.Hash.Definitions.hash_alg -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.nat"
] | [] | false | false | false | true | false | let word_length: hash_alg -> Tot nat =
| function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8 | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.block_word_length | val block_word_length : a: Spec.Hash.Definitions.hash_alg -> Prims.int | let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 218,
"start_col": 0,
"start_line": 206
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"FStar.Pervasives.normalize_term",
"Prims.int",
"Prims.op_Division",
"Spec.Hash.Definitions.rate",
"Spec.Hash.Definitions.SHA3_224",
"Spec.Hash.Definitions.SHA3_256",
"Spec.Hash.Definitions.SHA3_384",
"Spec.Hash.Definitions.SHA3_512",
"Spec.Hash.Definitions.Shake128",
"Spec.Hash.Definitions.Shake256"
] | [] | false | false | false | true | false | let block_word_length (a: hash_alg) =
| match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 | Blake2S | Blake2B -> 16 | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.extra_state | val extra_state : a: Spec.Hash.Definitions.hash_alg -> Type0 | let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 75,
"end_line": 243,
"start_col": 0,
"start_line": 238
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Spec.Hash.Definitions.block_length",
"Prims.unit"
] | [] | false | false | false | true | true | let extra_state a =
| match a with
| Blake2S | Blake2B -> n: nat{n % block_length a = 0}
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 -> unit | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.len_length | val len_length: maxed_hash_alg -> Tot nat | val len_length: maxed_hash_alg -> Tot nat | let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 154,
"start_col": 0,
"start_line": 149
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | _: Spec.Hash.Definitions.maxed_hash_alg -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.maxed_hash_alg",
"Prims.nat"
] | [] | false | false | false | true | false | let len_length: maxed_hash_alg -> Tot nat =
| function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16 | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.pad_t | val pad_t : a: Spec.Hash.Definitions.md_alg -> Type0 | let pad_t (a: md_alg) =
l:nat { l `less_than_max_input_length` a } ->
b:bytes { (Seq.length b + l) % block_length a = 0 } | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 345,
"start_col": 0,
"start_line": 343
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8
(* Input data, multiple of a block length. *)
let bytes_block a =
l:bytes { Seq.length l = block_length a }
(* Input data, multiple of a block length. *)
let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 }
let output_length = function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512
| Blake2S
| Blake2B -> unit
let hash_length' a (l: output_length a): Lib.IntTypes.size_nat =
if is_shake a then l else hash_length a
(* Output data, i.e. the final hash (tag). *)
let bytes_hash a =
b:bytes { Seq.length b = hash_length a }
let bytes_hash' a l =
b:bytes { Seq.length b = hash_length' a l }
(** The types for the core functions *)
let init_t (a: hash_alg) = words_state a
let update_t (a: md_alg) =
h:words_state a ->
l:bytes { Seq.length l = block_length a } ->
words_state a
let less_than_max_input_length l a =
match max_input_length a with
| Some max -> l <= max
| None -> true | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.md_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.md_alg",
"Prims.nat",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length",
"Spec.Hash.Definitions.bytes",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.block_length"
] | [] | false | false | false | true | true | let pad_t (a: md_alg) =
| l: nat{l `less_than_max_input_length` a} -> b: bytes{(Seq.length b + l) % block_length a = 0} | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.finish_t | val finish_t : a: Spec.Hash.Definitions.hash_alg -> Type0 | let finish_t (a: hash_alg) =
h:words_state a ->
l: output_length a ->
bytes_hash' a l | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 350,
"start_col": 0,
"start_line": 347
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8
(* Input data, multiple of a block length. *)
let bytes_block a =
l:bytes { Seq.length l = block_length a }
(* Input data, multiple of a block length. *)
let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 }
let output_length = function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512
| Blake2S
| Blake2B -> unit
let hash_length' a (l: output_length a): Lib.IntTypes.size_nat =
if is_shake a then l else hash_length a
(* Output data, i.e. the final hash (tag). *)
let bytes_hash a =
b:bytes { Seq.length b = hash_length a }
let bytes_hash' a l =
b:bytes { Seq.length b = hash_length' a l }
(** The types for the core functions *)
let init_t (a: hash_alg) = words_state a
let update_t (a: md_alg) =
h:words_state a ->
l:bytes { Seq.length l = block_length a } ->
words_state a
let less_than_max_input_length l a =
match max_input_length a with
| Some max -> l <= max
| None -> true
let pad_t (a: md_alg) =
l:nat { l `less_than_max_input_length` a } ->
b:bytes { (Seq.length b + l) % block_length a = 0 } | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.output_length",
"Spec.Hash.Definitions.bytes_hash'"
] | [] | false | false | false | true | true | let finish_t (a: hash_alg) =
| h: words_state a -> l: output_length a -> bytes_hash' a l | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.len_v | val len_v: a:maxed_hash_alg -> len_t a -> nat | val len_v: a:maxed_hash_alg -> len_t a -> nat | let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 145,
"start_col": 0,
"start_line": 140
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.maxed_hash_alg -> _: Spec.Hash.Definitions.len_t a -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.maxed_hash_alg",
"Lib.IntTypes.uint_v",
"Lib.IntTypes.U64",
"Lib.IntTypes.PUB",
"Lib.IntTypes.U128",
"Spec.Hash.Definitions.len_t",
"Prims.nat"
] | [] | false | false | false | false | false | let len_v =
| function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.hash_word_length | val hash_word_length (a: md_alg) : Tot nat | val hash_word_length (a: md_alg) : Tot nat | let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 257,
"start_col": 0,
"start_line": 251
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.md_alg -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.md_alg",
"Prims.nat"
] | [] | false | false | false | true | false | let hash_word_length: a: md_alg -> Tot nat =
| function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8 | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.bytes_block | val bytes_block : a: Spec.Hash.Definitions.hash_alg -> Type0 | let bytes_block a =
l:bytes { Seq.length l = block_length a } | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 304,
"start_col": 0,
"start_line": 303
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_disEquality",
"Prims.op_GreaterThanOrEqual",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.block_length"
] | [] | false | false | false | true | true | let bytes_block a =
| l: bytes{Seq.length l = block_length a} | false |
|
DivAction.fst | DivAction.bind | val bind (a b: Type) (v: repr a) (f: (a -> repr b)) : repr b | val bind (a b: Type) (v: repr a) (f: (a -> repr b)) : repr b | let bind (a b : Type) (v : repr a) (f : (a -> repr b)) : repr b =
fun () -> f (v ()) () | {
"file_name": "examples/layeredeffects/DivAction.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 9,
"start_col": 0,
"start_line": 8
} | module DivAction
let repr (a : Type) : Type = unit -> Dv a
let return (a : Type) (x : a) : repr a =
fun () -> x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "DivAction.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 | a: Type -> b: Type -> v: DivAction.repr a -> f: (_: a -> DivAction.repr b) -> DivAction.repr b | Prims.Tot | [
"total"
] | [] | [
"DivAction.repr",
"Prims.unit"
] | [] | false | false | false | true | false | let bind (a b: Type) (v: repr a) (f: (a -> repr b)) : repr b =
| fun () -> f (v ()) () | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.nat_to_len | val nat_to_len : a: Spec.Hash.Definitions.maxed_hash_alg ->
n: Prims.nat{n <= Lib.IntTypes.maxint (Spec.Hash.Definitions.len_int_type a)}
-> u82:
Lib.IntTypes.int_t (Spec.Hash.Definitions.len_int_type a) Lib.IntTypes.PUB
{Lib.IntTypes.v u82 == n} | let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 127,
"start_col": 0,
"start_line": 126
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 |
a: Spec.Hash.Definitions.maxed_hash_alg ->
n: Prims.nat{n <= Lib.IntTypes.maxint (Spec.Hash.Definitions.len_int_type a)}
-> u82:
Lib.IntTypes.int_t (Spec.Hash.Definitions.len_int_type a) Lib.IntTypes.PUB
{Lib.IntTypes.v u82 == n} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.maxed_hash_alg",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.maxint",
"Spec.Hash.Definitions.len_int_type",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.PUB",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Lib.IntTypes.range_t",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let nat_to_len (a: maxed_hash_alg) (n: nat{n <= maxint (len_int_type a)}) =
| mk_int #(len_int_type a) #PUB n | false |
|
DivAction.fst | DivAction.return | val return (a: Type) (x: a) : repr a | val return (a: Type) (x: a) : repr a | let return (a : Type) (x : a) : repr a =
fun () -> x | {
"file_name": "examples/layeredeffects/DivAction.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 6,
"start_col": 0,
"start_line": 5
} | module DivAction
let repr (a : Type) : Type = unit -> Dv a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "DivAction.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 | a: Type -> x: a -> DivAction.repr a | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"DivAction.repr"
] | [] | false | false | false | true | false | let return (a: Type) (x: a) : repr a =
| fun () -> x | false |
DivAction.fst | DivAction.test | val test (x: int) : Dv int | val test (x: int) : Dv int | let test (x:int) : Dv int = reify (good_div x) () | {
"file_name": "examples/layeredeffects/DivAction.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 51,
"start_col": 0,
"start_line": 51
} | module DivAction
let repr (a : Type) : Type = unit -> Dv a
let return (a : Type) (x : a) : repr a =
fun () -> x
let bind (a b : Type) (v : repr a) (f : (a -> repr b)) : repr b =
fun () -> f (v ()) ()
total
reifiable
reflectable
effect {
ID (a:Type)
with {repr; return; bind}
}
let lift_pure_nd (a:Type) (wp:pure_wp a) (f:unit -> PURE a wp) :
Pure (repr a) (requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ ->
let r = f () in
r
sub_effect PURE ~> ID = lift_pure_nd
val fix : #a:_ -> #b:_ -> ((a -> ID b) -> (a -> ID b)) -> (a -> ID b)
let fix #a #b f =
let reified : (a -> Dv b) -> (a -> Dv b) =
fun g x ->
let reflected_g : (a -> ID b) =
fun x -> ID?.reflect (fun () -> g x)
in
reify (f reflected_g x) ()
in
let rec fixed : (a -> Dv b) =
fun x -> reified fixed x
in
let reflected : a -> ID b =
fun x -> ID?.reflect (fun () -> fixed x)
in
reflected
[@@expect_failure]
let rec bad_div (x:int) : ID int = bad_div x
let good_div : int -> ID int = fix #int #int (fun f x -> f x) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "DivAction.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 | x: Prims.int -> FStar.Pervasives.Dv Prims.int | FStar.Pervasives.Dv | [] | [] | [
"Prims.int",
"DivAction.good_div"
] | [] | false | true | false | false | false | let test (x: int) : Dv int =
| reify (good_div x) () | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.hash_length | val hash_length (a: hash_alg{not (is_shake a)}) : Lib.IntTypes.(n: size_nat{n > 0}) | val hash_length (a: hash_alg{not (is_shake a)}) : Lib.IntTypes.(n: size_nat{n > 0}) | let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 272,
"start_col": 0,
"start_line": 261
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg{Prims.op_Negation (Spec.Hash.Definitions.is_shake a)}
-> n: Lib.IntTypes.size_nat{n > 0} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Prims.op_Negation",
"Spec.Hash.Definitions.is_shake",
"Spec.Hash.Definitions.is_md",
"FStar.Mul.op_Star",
"Spec.Hash.Definitions.word_length",
"Spec.Hash.Definitions.hash_word_length",
"Prims.bool",
"Lib.IntTypes.size_nat",
"Prims.op_GreaterThan"
] | [] | false | false | false | false | false | let hash_length (a: hash_alg{not (is_shake a)}) : Lib.IntTypes.(n: size_nat{n > 0}) =
| let open FStar.Mul in
if is_md a
then word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8 | false |
DivAction.fst | DivAction.fix | val fix : #a:_ -> #b:_ -> ((a -> ID b) -> (a -> ID b)) -> (a -> ID b) | val fix : #a:_ -> #b:_ -> ((a -> ID b) -> (a -> ID b)) -> (a -> ID b) | let fix #a #b f =
let reified : (a -> Dv b) -> (a -> Dv b) =
fun g x ->
let reflected_g : (a -> ID b) =
fun x -> ID?.reflect (fun () -> g x)
in
reify (f reflected_g x) ()
in
let rec fixed : (a -> Dv b) =
fun x -> reified fixed x
in
let reflected : a -> ID b =
fun x -> ID?.reflect (fun () -> fixed x)
in
reflected | {
"file_name": "examples/layeredeffects/DivAction.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 11,
"end_line": 44,
"start_col": 0,
"start_line": 30
} | module DivAction
let repr (a : Type) : Type = unit -> Dv a
let return (a : Type) (x : a) : repr a =
fun () -> x
let bind (a b : Type) (v : repr a) (f : (a -> repr b)) : repr b =
fun () -> f (v ()) ()
total
reifiable
reflectable
effect {
ID (a:Type)
with {repr; return; bind}
}
let lift_pure_nd (a:Type) (wp:pure_wp a) (f:unit -> PURE a wp) :
Pure (repr a) (requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ ->
let r = f () in
r
sub_effect PURE ~> ID = lift_pure_nd | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "DivAction.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 | f: (_: (_: a -> DivAction.ID b) -> _: a -> DivAction.ID b) -> _: a -> DivAction.ID b | DivAction.ID | [] | [] | [
"Prims.unit"
] | [] | false | true | false | false | false | let fix #a #b f =
| let reified: (a -> Dv b) -> (a -> Dv b) =
fun g x ->
let reflected_g:(a -> ID b) = fun x -> ID?.reflect (fun () -> g x) in
reify (f reflected_g x) ()
in
let rec fixed:(a -> Dv b) = fun x -> reified fixed x in
let reflected: a -> ID b = fun x -> ID?.reflect (fun () -> fixed x) in
reflected | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.len_len | val len_len (a: maxed_hash_alg) : Tot (n: size_t{v n = len_length a}) | val len_len (a: maxed_hash_alg) : Tot (n: size_t{v n = len_length a}) | let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 162,
"start_col": 0,
"start_line": 158
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.maxed_hash_alg
-> n:
Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{Lib.IntTypes.v n = Spec.Hash.Definitions.len_length a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.maxed_hash_alg",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v",
"Spec.Hash.Definitions.len_length"
] | [] | false | false | false | false | false | let len_len: a: maxed_hash_alg -> Tot (n: size_t{v n = len_length a}) =
| function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.pad_length | val pad_length (a: md_alg) (len: nat) : Tot (n: nat{(len + n) % block_length a = 0}) | val pad_length (a: md_alg) (len: nat) : Tot (n: nat{(len + n) % block_length a = 0}) | let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 282,
"start_col": 0,
"start_line": 281
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.md_alg -> len: Prims.nat
-> n: Prims.nat{(len + n) % Spec.Hash.Definitions.block_length a = 0} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.md_alg",
"Prims.nat",
"Prims.op_Addition",
"Spec.Hash.Definitions.pad0_length",
"Spec.Hash.Definitions.len_length",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Spec.Hash.Definitions.block_length"
] | [] | false | false | false | false | false | let pad_length (a: md_alg) (len: nat) : Tot (n: nat{(len + n) % block_length a = 0}) =
| pad0_length a len + 1 + len_length a | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.words_state | val words_state : a: Spec.Hash.Definitions.hash_alg -> Type0 | let words_state a = lseq (word a) (state_word_length a) | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 247,
"start_col": 0,
"start_line": 247
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Lib.Sequence.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.state_word_length"
] | [] | false | false | false | true | true | let words_state a =
| lseq (word a) (state_word_length a) | false |
|
DivAction.fst | DivAction.good_div | val good_div: int -> ID int | val good_div: int -> ID int | let good_div : int -> ID int = fix #int #int (fun f x -> f x) | {
"file_name": "examples/layeredeffects/DivAction.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 61,
"end_line": 49,
"start_col": 0,
"start_line": 49
} | module DivAction
let repr (a : Type) : Type = unit -> Dv a
let return (a : Type) (x : a) : repr a =
fun () -> x
let bind (a b : Type) (v : repr a) (f : (a -> repr b)) : repr b =
fun () -> f (v ()) ()
total
reifiable
reflectable
effect {
ID (a:Type)
with {repr; return; bind}
}
let lift_pure_nd (a:Type) (wp:pure_wp a) (f:unit -> PURE a wp) :
Pure (repr a) (requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ ->
let r = f () in
r
sub_effect PURE ~> ID = lift_pure_nd
val fix : #a:_ -> #b:_ -> ((a -> ID b) -> (a -> ID b)) -> (a -> ID b)
let fix #a #b f =
let reified : (a -> Dv b) -> (a -> Dv b) =
fun g x ->
let reflected_g : (a -> ID b) =
fun x -> ID?.reflect (fun () -> g x)
in
reify (f reflected_g x) ()
in
let rec fixed : (a -> Dv b) =
fun x -> reified fixed x
in
let reflected : a -> ID b =
fun x -> ID?.reflect (fun () -> fixed x)
in
reflected
[@@expect_failure]
let rec bad_div (x:int) : ID int = bad_div x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "DivAction.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.int -> DivAction.ID Prims.int | DivAction.ID | [] | [] | [
"DivAction.fix",
"Prims.int"
] | [] | false | true | false | false | false | let good_div: int -> ID int =
| fix #int #int (fun f x -> f x) | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.max_input_length | val max_input_length: hash_alg -> option pos | val max_input_length: hash_alg -> option pos | let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 75,
"end_line": 105,
"start_col": 0,
"start_line": 99
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | _: Spec.Hash.Definitions.hash_alg -> FStar.Pervasives.Native.option Prims.pos | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"FStar.Pervasives.Native.Some",
"Prims.pos",
"Prims.op_Subtraction",
"Prims.pow2",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let max_input_length: hash_alg -> option pos =
| function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.row | val row : a: Spec.Hash.Definitions.blake_alg -> Type0 | let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 177,
"start_col": 0,
"start_line": 177
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.blake_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.blake_alg",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint_t",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.SEC"
] | [] | false | false | false | true | true | let row (a: blake_alg) =
| lseq (uint_t (word_t a) SEC) 4 | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.bytes_hash | val bytes_hash : a: Spec.Hash.Definitions.hash_alg{Prims.op_Negation (Spec.Hash.Definitions.is_shake a)} -> Type0 | let bytes_hash a =
b:bytes { Seq.length b = hash_length a } | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 324,
"start_col": 0,
"start_line": 323
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8
(* Input data, multiple of a block length. *)
let bytes_block a =
l:bytes { Seq.length l = block_length a }
(* Input data, multiple of a block length. *)
let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 }
let output_length = function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512
| Blake2S
| Blake2B -> unit
let hash_length' a (l: output_length a): Lib.IntTypes.size_nat =
if is_shake a then l else hash_length a | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg{Prims.op_Negation (Spec.Hash.Definitions.is_shake a)} -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Prims.op_Negation",
"Spec.Hash.Definitions.is_shake",
"Spec.Hash.Definitions.bytes",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.hash_length"
] | [] | false | false | false | false | true | let bytes_hash a =
| b: bytes{Seq.length b = hash_length a} | false |
|
DivAction.fst | DivAction.lift_pure_nd | val lift_pure_nd (a: Type) (wp: pure_wp a) (f: (unit -> PURE a wp))
: Pure (repr a) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) | val lift_pure_nd (a: Type) (wp: pure_wp a) (f: (unit -> PURE a wp))
: Pure (repr a) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) | let lift_pure_nd (a:Type) (wp:pure_wp a) (f:unit -> PURE a wp) :
Pure (repr a) (requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ ->
let r = f () in
r | {
"file_name": "examples/layeredeffects/DivAction.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 25,
"start_col": 0,
"start_line": 19
} | module DivAction
let repr (a : Type) : Type = unit -> Dv a
let return (a : Type) (x : a) : repr a =
fun () -> x
let bind (a b : Type) (v : repr a) (f : (a -> repr b)) : repr b =
fun () -> f (v ()) ()
total
reifiable
reflectable
effect {
ID (a:Type)
with {repr; return; bind}
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "DivAction.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 | a: Type -> wp: Prims.pure_wp a -> f: (_: Prims.unit -> Prims.PURE a)
-> Prims.Pure (DivAction.repr a) | Prims.Pure | [] | [] | [
"Prims.pure_wp",
"Prims.unit",
"FStar.Monotonic.Pure.elim_pure_wp_monotonicity",
"DivAction.repr",
"Prims.l_True"
] | [] | false | false | false | false | false | let lift_pure_nd (a: Type) (wp: pure_wp a) (f: (unit -> PURE a wp))
: Pure (repr a) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) =
| FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
fun _ ->
let r = f () in
r | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.update_t | val update_t : a: Spec.Hash.Definitions.md_alg -> Type0 | let update_t (a: md_alg) =
h:words_state a ->
l:bytes { Seq.length l = block_length a } ->
words_state a | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 336,
"start_col": 0,
"start_line": 333
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8
(* Input data, multiple of a block length. *)
let bytes_block a =
l:bytes { Seq.length l = block_length a }
(* Input data, multiple of a block length. *)
let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 }
let output_length = function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512
| Blake2S
| Blake2B -> unit
let hash_length' a (l: output_length a): Lib.IntTypes.size_nat =
if is_shake a then l else hash_length a
(* Output data, i.e. the final hash (tag). *)
let bytes_hash a =
b:bytes { Seq.length b = hash_length a }
let bytes_hash' a l =
b:bytes { Seq.length b = hash_length' a l }
(** The types for the core functions *)
let init_t (a: hash_alg) = words_state a | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.md_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.md_alg",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.block_length"
] | [] | false | false | false | true | true | let update_t (a: md_alg) =
| h: words_state a -> l: bytes{Seq.length l = block_length a} -> words_state a | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.rate | val rate (a: keccak_alg) : (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) | val rate (a: keccak_alg) : (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) | let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 203,
"start_col": 0,
"start_line": 196
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.keccak_alg -> rate: Lib.IntTypes.size_nat{0 < rate / 8 /\ rate / 8 <= 200} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.keccak_alg",
"Lib.IntTypes.size_nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.op_LessThanOrEqual"
] | [] | false | false | false | false | false | let rate (a: keccak_alg) : (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
| match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088 | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.output_length | val output_length : _: Spec.Hash.Definitions.hash_alg -> Type0 | let output_length = function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512
| Blake2S
| Blake2B -> unit | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 317,
"start_col": 0,
"start_line": 310
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8
(* Input data, multiple of a block length. *)
let bytes_block a =
l:bytes { Seq.length l = block_length a }
(* Input data, multiple of a block length. *)
let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 } | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | _: Spec.Hash.Definitions.hash_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Lib.IntTypes.size_nat",
"Prims.unit"
] | [] | false | false | false | true | true | let output_length =
| function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Blake2S
| Blake2B -> unit | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.word | val word : a: Spec.Hash.Definitions.hash_alg -> Type0 | let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 92,
"end_line": 185,
"start_col": 0,
"start_line": 180
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.row",
"Lib.IntTypes.uint_t",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.SEC"
] | [] | false | false | false | true | true | let word (a: hash_alg) =
| match a with
| Blake2S | Blake2B -> row a
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 -> uint_t (word_t a) SEC | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.bytes_hash' | val bytes_hash' : a: Spec.Hash.Definitions.hash_alg -> l: Spec.Hash.Definitions.output_length a -> Type0 | let bytes_hash' a l =
b:bytes { Seq.length b = hash_length' a l } | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 327,
"start_col": 0,
"start_line": 326
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8
(* Input data, multiple of a block length. *)
let bytes_block a =
l:bytes { Seq.length l = block_length a }
(* Input data, multiple of a block length. *)
let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 }
let output_length = function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512
| Blake2S
| Blake2B -> unit
let hash_length' a (l: output_length a): Lib.IntTypes.size_nat =
if is_shake a then l else hash_length a
(* Output data, i.e. the final hash (tag). *)
let bytes_hash a =
b:bytes { Seq.length b = hash_length a } | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> l: Spec.Hash.Definitions.output_length a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.output_length",
"Spec.Hash.Definitions.bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.hash_length'"
] | [] | false | false | false | false | true | let bytes_hash' a l =
| b: bytes{Seq.length b = hash_length' a l} | false |
|
Hacl.K256.PrecompTable.fst | Hacl.K256.PrecompTable.precomp_basepoint_table_list_w5 | val precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 480} | val precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 480} | let precomp_basepoint_table_list_w5: x:list uint64{FStar.List.Tot.length x = 480} =
normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 31) | {
"file_name": "code/k256/Hacl.K256.PrecompTable.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 80,
"end_line": 283,
"start_col": 0,
"start_line": 282
} | module Hacl.K256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module SPT = Hacl.Spec.PrecompBaseTable
module SPT256 = Hacl.Spec.PrecompBaseTable256
module SPTK = Hacl.Spec.K256.PrecompTable
module S = Spec.K256
module SL = Spec.K256.Lemmas
open Hacl.Impl.K256.Point
include Hacl.Impl.K256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let proj_point_to_list p =
SPTK.proj_point_to_list_lemma p;
SPTK.proj_point_to_list p
let lemma_refl x =
SPTK.proj_point_to_list_lemma x
//-----------------
inline_for_extraction noextract
let proj_g_pow2_64 : S.proj_point =
[@inline_let]
let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in
[@inline_let]
let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in
[@inline_let]
let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in
(rX, rY, rZ)
val lemma_proj_g_pow2_64_eval : unit ->
Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64)
let lemma_proj_g_pow2_64_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64);
let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in
let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in
let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
inline_for_extraction noextract
let proj_g_pow2_128 : S.proj_point =
[@inline_let]
let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in
[@inline_let]
let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in
[@inline_let]
let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in
(rX, rY, rZ)
val lemma_proj_g_pow2_128_eval : unit ->
Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
let lemma_proj_g_pow2_128_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64);
let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in
let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in
let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
inline_for_extraction noextract
let proj_g_pow2_192 : S.proj_point =
[@inline_let]
let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in
[@inline_let]
let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in
[@inline_let]
let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in
(rX, rY, rZ)
val lemma_proj_g_pow2_192_eval : unit ->
Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
let lemma_proj_g_pow2_192_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64);
let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in
let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in
let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
// let proj_g_pow2_64 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64)
// let proj_g_pow2_128 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64)
// let proj_g_pow2_192 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64)
inline_for_extraction noextract
let proj_g_pow2_64_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_64)
inline_for_extraction noextract
let proj_g_pow2_128_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_128)
inline_for_extraction noextract
let proj_g_pow2_192_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64);
Seq.seq_of_list proj_g_pow2_64_list
let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128);
Seq.seq_of_list proj_g_pow2_128_list
let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192);
Seq.seq_of_list proj_g_pow2_192_list
val proj_g_pow2_64_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
let proj_g_pow2_64_lemma () =
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g
val proj_g_pow2_128_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
let proj_g_pow2_128_lemma () =
lemma_proj_g_pow2_128_eval ();
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g
val proj_g_pow2_192_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
let proj_g_pow2_192_lemma () =
lemma_proj_g_pow2_192_eval ();
lemma_proj_g_pow2_128_eval ();
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g
let proj_g_pow2_64_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64);
proj_g_pow2_64_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_64
let proj_g_pow2_128_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128);
proj_g_pow2_128_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_128
let proj_g_pow2_192_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192);
proj_g_pow2_192_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_192
let mk_proj_g_pow2_64 () =
createL proj_g_pow2_64_list
let mk_proj_g_pow2_128 () =
createL proj_g_pow2_128_list
let mk_proj_g_pow2_192 () =
createL proj_g_pow2_192_list
//----------------
/// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G]
inline_for_extraction noextract
let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} =
normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15)
let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240 =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15);
Seq.seq_of_list precomp_basepoint_table_list_w4
let precomp_basepoint_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15);
SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 16 precomp_basepoint_table_lseq_w4
let precomp_basepoint_table_w4:
x:glbuffer uint64 240ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} =
createL_global precomp_basepoint_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)]
inline_for_extraction noextract
let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} =
normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15)
let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 240 =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15);
Seq.seq_of_list precomp_g_pow2_64_table_list_w4
let precomp_g_pow2_64_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15);
SPT.precomp_base_table_lemma mk_k256_precomp_base_table
proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_64_lemma ()
let precomp_g_pow2_64_table_w4:
x:glbuffer uint64 240ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_64_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)]
inline_for_extraction noextract
let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} =
normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_128 15)
let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 240 =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_128 15);
Seq.seq_of_list precomp_g_pow2_128_table_list_w4
let precomp_g_pow2_128_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_128 15);
SPT.precomp_base_table_lemma mk_k256_precomp_base_table
proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_128_lemma ()
let precomp_g_pow2_128_table_w4:
x:glbuffer uint64 240ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_128_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)]
inline_for_extraction noextract
let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} =
normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_192 15)
let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 240 =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_192 15);
Seq.seq_of_list precomp_g_pow2_192_table_list_w4
let precomp_g_pow2_192_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_192 15);
SPT.precomp_base_table_lemma mk_k256_precomp_base_table
proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_192_lemma ()
let precomp_g_pow2_192_table_w4:
x:glbuffer uint64 240ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_192_table_list_w4
/// window size = 5; precomputed table = [[0]G, [1]G, ..., [31]G] | {
"checked_file": "/",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable256.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.K256.PrecompTable.fsti.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"Hacl.Impl.K256.Group.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.PrecompTable.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length x = 480} | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.normalize_term",
"Prims.list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Hacl.Spec.PrecompBaseTable.precomp_base_table_list",
"Spec.K256.PointOps.proj_point",
"FStar.UInt32.uint_to_t",
"Hacl.K256.PrecompTable.mk_k256_precomp_base_table",
"Spec.K256.PointOps.g"
] | [] | false | false | false | false | false | let precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 480} =
| normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 31) | false |
Options.fst | Options.valid_string | val valid_string (valid: (string -> Tot bool)) : Tot Type0 | val valid_string (valid: (string -> Tot bool)) : Tot Type0 | let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true }) | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 33,
"end_line": 14,
"start_col": 0,
"start_line": 11
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | valid: (_: Prims.string -> Prims.bool) -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.bool",
"Prims.eq2"
] | [] | false | false | false | true | true | let valid_string (valid: (string -> Tot bool)) : Tot Type0 =
| (s: string{valid s == true}) | false |
StructUpdate.fst | StructUpdate.comp | val comp (#a #b: _) (x y: t a b) : prop | val comp (#a #b: _) (x y: t a b) : prop | let comp #a #b (x y:t a b) : prop =
match x, y with
| Neither, _
| _, Neither
| First _, Second _
| Second _, First _ -> True
| _ -> False | {
"file_name": "share/steel/examples/steel/StructUpdate.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 14,
"end_line": 18,
"start_col": 0,
"start_line": 12
} | module StructUpdate
module P = FStar.PCM
module M = Steel.Memory
open FStar.PCM
type t (a:Type) (b:Type) =
| Both : a -> b -> t a b
| First : a -> t a b
| Second : b -> t a b
| Neither : t a b | {
"checked_file": "/",
"dependencies": [
"Steel.PCMReference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "StructUpdate.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.PCM",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | x: StructUpdate.t a b -> y: StructUpdate.t a b -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"StructUpdate.t",
"FStar.Pervasives.Native.Mktuple2",
"Prims.l_True",
"FStar.Pervasives.Native.tuple2",
"Prims.l_False",
"Prims.prop"
] | [] | false | false | false | true | true | let comp #a #b (x: t a b) (y: t a b) : prop =
| match x, y with
| Neither, _ | _, Neither | First _, Second _ | Second _, First _ -> True
| _ -> False | false |
Options.fst | Options.always_valid | val always_valid: string -> Tot bool | val always_valid: string -> Tot bool | let always_valid (_: string) : Tot bool = true | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 46,
"end_line": 16,
"start_col": 0,
"start_line": 16
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true }) | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.bool"
] | [] | false | false | false | true | false | let always_valid (_: string) : Tot bool =
| true | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.state_word_length | val state_word_length : a: Spec.Hash.Definitions.hash_alg -> Prims.int | let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 235,
"start_col": 0,
"start_line": 228
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.int"
] | [] | false | false | false | true | false | let state_word_length a =
| match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8 | false |
|
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.less_than_max_input_length | val less_than_max_input_length : l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool | let less_than_max_input_length l a =
match max_input_length a with
| Some max -> l <= max
| None -> true | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 341,
"start_col": 0,
"start_line": 338
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8
(* Input data, multiple of a block length. *)
let bytes_block a =
l:bytes { Seq.length l = block_length a }
(* Input data, multiple of a block length. *)
let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 }
let output_length = function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512
| Blake2S
| Blake2B -> unit
let hash_length' a (l: output_length a): Lib.IntTypes.size_nat =
if is_shake a then l else hash_length a
(* Output data, i.e. the final hash (tag). *)
let bytes_hash a =
b:bytes { Seq.length b = hash_length a }
let bytes_hash' a l =
b:bytes { Seq.length b = hash_length' a l }
(** The types for the core functions *)
let init_t (a: hash_alg) = words_state a
let update_t (a: md_alg) =
h:words_state a ->
l:bytes { Seq.length l = block_length a } ->
words_state a | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.max_input_length",
"Prims.pos",
"Prims.op_LessThanOrEqual",
"Prims.bool"
] | [] | false | false | false | true | false | let less_than_max_input_length l a =
| match max_input_length a with
| Some max -> l <= max
| None -> true | false |
|
Options.fst | Options.batch | val batch:ref bool | val batch:ref bool | let batch : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 34,
"end_line": 49,
"start_col": 0,
"start_line": 49
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let batch:ref bool =
| alloc false | false |
Options.fst | Options.check_config_file_name | val check_config_file_name (fn: string) : bool | val check_config_file_name (fn: string) : bool | let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config" | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 29,
"end_line": 36,
"start_col": 0,
"start_line": 32
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix' | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | fn: Prims.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.op_AmpAmp",
"Options.starts_with_capital",
"Options.ends_with",
"OS.basename",
"Prims.bool"
] | [] | false | false | false | true | false | let check_config_file_name (fn: string) : bool =
| let fn = OS.basename fn in
starts_with_capital fn && ends_with fn ".3d.config" | false |
Options.fst | Options.clang_format_executable | val clang_format_executable:ref (option vstring) | val clang_format_executable:ref (option vstring) | let clang_format_executable : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 63,
"end_line": 51,
"start_col": 0,
"start_line": 51
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let clang_format_executable:ref (option vstring) =
| alloc None | false |
Options.fst | Options.arg0 | val arg0:ref (option vstring) | val arg0:ref (option vstring) | let arg0 : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 44,
"end_line": 47,
"start_col": 0,
"start_line": 47
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *) | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let arg0:ref (option vstring) =
| alloc None | false |
Options.fst | Options.cleanup | val cleanup:ref bool | val cleanup:ref bool | let cleanup : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 36,
"end_line": 52,
"start_col": 0,
"start_line": 52
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let cleanup:ref bool =
| alloc false | false |
Options.fst | Options.inplace_hashes | val inplace_hashes:ref (list vstring) | val inplace_hashes:ref (list vstring) | let inplace_hashes : ref (list vstring) = alloc [] | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 50,
"end_line": 55,
"start_col": 0,
"start_line": 55
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (Prims.list Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.list",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"Prims.Nil",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let inplace_hashes:ref (list vstring) =
| alloc [] | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.pad0_length | val pad0_length (a: md_alg) (len: nat)
: Tot (n: nat{(len + 1 + n + len_length a) % block_length a = 0}) | val pad0_length (a: md_alg) (len: nat)
: Tot (n: nat{(len + 1 + n + len_length a) % block_length a = 0}) | let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 278,
"start_col": 0,
"start_line": 277
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.md_alg -> len: Prims.nat
-> n:
Prims.nat
{ (len + 1 + n + Spec.Hash.Definitions.len_length a) % Spec.Hash.Definitions.block_length a =
0 } | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.md_alg",
"Prims.nat",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"Spec.Hash.Definitions.block_length",
"Prims.op_Addition",
"Spec.Hash.Definitions.len_length",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int"
] | [] | false | false | false | false | false | let pad0_length (a: md_alg) (len: nat)
: Tot (n: nat{(len + 1 + n + len_length a) % block_length a = 0}) =
| (block_length a - (len + len_length a + 1)) % block_length a | false |
Options.fst | Options.add_include | val add_include:ref (list vstring) | val add_include:ref (list vstring) | let add_include : ref (list vstring) = alloc [] | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 47,
"end_line": 48,
"start_col": 0,
"start_line": 48
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *) | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (Prims.list Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.list",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"Prims.Nil",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let add_include:ref (list vstring) =
| alloc [] | false |
Options.fst | Options.vstring | val vstring : Type0 | let vstring = valid_string always_valid | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 39,
"end_line": 43,
"start_col": 0,
"start_line": 43
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx) | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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"
] | [] | [
"Options.valid_string",
"Options.always_valid"
] | [] | false | false | false | true | true | let vstring =
| valid_string always_valid | false |
|
Options.fst | Options.config_file | val config_file:ref (option (valid_string check_config_file_name)) | val config_file:ref (option (valid_string check_config_file_name)) | let config_file : ref (option (valid_string check_config_file_name)) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 81,
"end_line": 53,
"start_col": 0,
"start_line": 53
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.check_config_file_name)) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.check_config_file_name",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let config_file:ref (option (valid_string check_config_file_name)) =
| alloc None | false |
Options.fst | Options.debug | val debug:ref bool | val debug:ref bool | let debug : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 34,
"end_line": 54,
"start_col": 0,
"start_line": 54
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let debug:ref bool =
| alloc false | false |
Options.fst | Options.json | val json:ref bool | val json:ref bool | let json : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 33,
"end_line": 57,
"start_col": 0,
"start_line": 57
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc [] | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let json:ref bool =
| alloc false | false |
Options.fst | Options.clang_format | val clang_format:ref bool | val clang_format:ref bool | let clang_format : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 41,
"end_line": 50,
"start_col": 0,
"start_line": 50
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc [] | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let clang_format:ref bool =
| alloc false | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.bytes_of_words | val bytes_of_words (a: hash_alg{is_md a})
: Tot
(#len: size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s: lseq (word a) len
-> Tot (lbytes FStar.Mul.(word_length a * len))) | val bytes_of_words (a: hash_alg{is_md a})
: Tot
(#len: size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s: lseq (word a) len
-> Tot (lbytes FStar.Mul.(word_length a * len))) | let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 71,
"end_line": 290,
"start_col": 0,
"start_line": 287
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 |
a: Spec.Hash.Definitions.hash_alg{Spec.Hash.Definitions.is_md a} ->
s: Lib.Sequence.lseq (Spec.Hash.Definitions.word a) len
-> Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(Spec.Hash.Definitions.word_length a * len) | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.Hash.Definitions.is_md",
"Lib.ByteSequence.uints_to_bytes_le",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.uints_to_bytes_be",
"Lib.IntTypes.U64",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply",
"Spec.Hash.Definitions.word_length",
"Lib.Sequence.lseq",
"Spec.Hash.Definitions.word",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8"
] | [] | false | false | false | false | false | let bytes_of_words: a: hash_alg{is_md a}
-> Tot
(#len: size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s: lseq (word a) len
-> Tot (lbytes FStar.Mul.(word_length a * len))) =
| function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.hash_length' | val hash_length' (a: _) (l: output_length a) : Lib.IntTypes.size_nat | val hash_length' (a: _) (l: output_length a) : Lib.IntTypes.size_nat | let hash_length' a (l: output_length a): Lib.IntTypes.size_nat =
if is_shake a then l else hash_length a | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 320,
"start_col": 0,
"start_line": 319
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC
let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC
(** The data format taken and returned by the hash specifications. *)
(* Input data. *)
type bytes = Seq.seq uint8
(* Input data, multiple of a block length. *)
let bytes_block a =
l:bytes { Seq.length l = block_length a }
(* Input data, multiple of a block length. *)
let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 }
let output_length = function
| Shake128 | Shake256 -> Lib.IntTypes.size_nat
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512
| Blake2S
| Blake2B -> unit | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | a: Spec.Hash.Definitions.hash_alg -> l: Spec.Hash.Definitions.output_length a
-> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.output_length",
"Spec.Hash.Definitions.is_shake",
"Prims.bool",
"Spec.Hash.Definitions.hash_length",
"Lib.IntTypes.size_nat"
] | [] | false | false | false | false | false | let hash_length' a (l: output_length a) : Lib.IntTypes.size_nat =
| if is_shake a then l else hash_length a | false |
Options.fst | Options.input_file | val input_file:ref (list string) | val input_file:ref (list string) | let input_file : ref (list string) = alloc [] | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 45,
"end_line": 56,
"start_col": 0,
"start_line": 56
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (Prims.list Prims.string) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.list",
"Prims.string",
"FStar.Heap.trivial_preorder",
"Prims.Nil",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let input_file:ref (list string) =
| alloc [] | false |
Options.fst | Options.skip_c_makefiles | val skip_c_makefiles:ref bool | val skip_c_makefiles:ref bool | let skip_c_makefiles : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 45,
"end_line": 62,
"start_col": 0,
"start_line": 62
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let skip_c_makefiles:ref bool =
| alloc false | false |
Options.fst | Options.no_copy_everparse_h | val no_copy_everparse_h:ref bool | val no_copy_everparse_h:ref bool | let no_copy_everparse_h : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 48,
"end_line": 58,
"start_col": 0,
"start_line": 58
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc [] | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let no_copy_everparse_h:ref bool =
| alloc false | false |
Options.fst | Options.save_hashes | val save_hashes:ref bool | val save_hashes:ref bool | let save_hashes : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 40,
"end_line": 60,
"start_col": 0,
"start_line": 60
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let save_hashes:ref bool =
| alloc false | false |
Options.fst | Options.output_dir | val output_dir:ref (option vstring) | val output_dir:ref (option vstring) | let output_dir : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 50,
"end_line": 59,
"start_col": 0,
"start_line": 59
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let output_dir:ref (option vstring) =
| alloc None | false |
Options.fst | Options.save_z3_transcript | val save_z3_transcript:ref (option vstring) | val save_z3_transcript:ref (option vstring) | let save_z3_transcript: ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 57,
"end_line": 61,
"start_col": 0,
"start_line": 61
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let save_z3_transcript:ref (option vstring) =
| alloc None | false |
Options.fst | Options.skip_deps | val skip_deps:ref bool | val skip_deps:ref bool | let skip_deps: ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 37,
"end_line": 63,
"start_col": 0,
"start_line": 63
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let skip_deps:ref bool =
| alloc false | false |
Options.fst | Options.skip_o_rules | val skip_o_rules:ref bool | val skip_o_rules:ref bool | let skip_o_rules: ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 40,
"end_line": 64,
"start_col": 0,
"start_line": 64
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let skip_o_rules:ref bool =
| alloc false | false |
Options.fst | Options.valid_micro_step | val valid_micro_step (str: string) : Tot bool | val valid_micro_step (str: string) : Tot bool | let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 14,
"end_line": 73,
"start_col": 0,
"start_line": 66
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | str: Prims.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_micro_step (str: string) : Tot bool =
| match str with
| "verify" | "extract" | "copy_clang_format" | "copy_everparse_h" | "emit_config" -> true
| _ -> false | false |
Options.fst | Options.micro_step | val micro_step:ref (option (valid_string valid_micro_step)) | val micro_step:ref (option (valid_string valid_micro_step)) | let micro_step : ref (option (valid_string valid_micro_step)) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 74,
"end_line": 75,
"start_col": 0,
"start_line": 75
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_micro_step)) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_micro_step",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let micro_step:ref (option (valid_string valid_micro_step)) =
| alloc None | false |
Options.fst | Options.produce_c_from_existing_krml | val produce_c_from_existing_krml:ref bool | val produce_c_from_existing_krml:ref bool | let produce_c_from_existing_krml : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 57,
"end_line": 77,
"start_col": 0,
"start_line": 77
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let produce_c_from_existing_krml:ref bool =
| alloc false | false |
Spec.Hash.Definitions.fst | Spec.Hash.Definitions.words_of_bytes | val words_of_bytes (a: hash_alg{is_md a})
: Tot
(
#len: size_nat{FStar.Mul.(len * word_length a) <= max_size_t} ->
b: lbytes FStar.Mul.(word_length a * len)
-> Tot (lseq (word a) len)) | val words_of_bytes (a: hash_alg{is_md a})
: Tot
(
#len: size_nat{FStar.Mul.(len * word_length a) <= max_size_t} ->
b: lbytes FStar.Mul.(word_length a * len)
-> Tot (lseq (word a) len)) | let words_of_bytes: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> b:lbytes FStar.Mul.(word_length a * len) -> Tot (lseq (word a) len)) = function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 73,
"end_line": 295,
"start_col": 0,
"start_line": 292
} | module Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
(* This module contains shared definitions across all hash algorithms. It
* defines a common, shared `hash_alg` type, along with word sizes, type of the
* working state, and other helpers. It also defines the type of the core functions
* init / update / pad / finish that any algorithm must implement in order to be
* turned into a complete hash construction.
*
* Some notes about terminology:
* - this module uses the HACL* naming convention, namely init/update/finish
* (Cédric uses init/compress/extract in EverCrypt.HMAC and above)
* - this module defines maximum lengths to be *bounds* (i.e. max_value + 1), a
* somewhat dubious convention that persists for historical reasons, but that
* is abandoned in miTLS via an extra indirection
*
* The following naming conventions are (tentatively) enforced.
* - underscores (no camelCase)
* - suffixes: _length for nat, _len for machine integer
* - by default, lengths are in bytes; we use _word_length or _bit_len as suffixes
* - for names that might conflict with their stateful counterparts, we prefix
* with the type, e.g. words_state or bytes_block
*)
(** Supported hash algorithms.
NOTE: this inductive is *append-only* because the constructors generate macro
definitions that various bindings (OCaml, Rust) have taken a dependency on.
So, in order to keep the numbering stable, we only append new cases, which is
why SHA3_224 comes after SHA3_256 (the former was added *after* the latter).
*)
type hash_alg =
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA1
| MD5
| Blake2S
| Blake2B
| SHA3_256
| SHA3_224
| SHA3_384
| SHA3_512
| Shake128
| Shake256
inline_for_extraction noextract
let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
inline_for_extraction noextract
let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false
inline_for_extraction noextract
let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false
inline_for_extraction noextract
let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let sha2_alg = a:hash_alg { is_sha2 a }
let keccak_alg = a:hash_alg { is_keccak a }
let blake_alg = a:hash_alg { is_blake a }
let md_alg = a:hash_alg { is_md a }
let fixed_len_alg = a:hash_alg { not (is_shake a) }
inline_for_extraction
let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B
inline_for_extraction
let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B
(** Maximum input data length. *)
(* In bytes. *)
inline_for_extraction
let max_input_length: hash_alg -> option pos = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> Some (pow2 61 - 1)
| SHA2_384 | SHA2_512 -> Some (pow2 125 - 1)
| Blake2S -> Some (pow2 64 - 1)
| Blake2B -> Some (pow2 128 - 1)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> None
let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) }
let sha2_alg_is_maxed (a: hash_alg): Lemma (requires (is_sha2 a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_sha2 a) ] = ()
let md_alg_is_maxed (a: hash_alg): Lemma (requires (is_md a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_md a) ] = ()
let blake_alg_is_maxed (a: hash_alg): Lemma (requires (is_blake a)) (ensures (Some? (max_input_length a))) [ SMTPat (is_blake a) ] = ()
// TODO: many of these definitions are only used by the MD padding scheme,
// meaning they should be defined over md_alg!
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_int_type: maxed_hash_alg -> inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128
inline_for_extraction
let nat_to_len (a:maxed_hash_alg) (n:nat{n <= maxint (len_int_type a)}) =
mk_int #(len_int_type a ) #PUB n
(* A type that can hold a maximum length, in bits. *)
inline_for_extraction
let len_t: hash_alg -> Type = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> pub_uint64
| SHA2_384 | SHA2_512 -> pub_uint128
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
| Blake2S -> pub_uint64
| Blake2B -> pub_uint128
val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> uint_v #U64 #PUB
| SHA2_384 | SHA2_512 -> uint_v #U128 #PUB
| Blake2S -> uint_v #U64 #PUB
| Blake2B -> uint_v #U128 #PUB
(* Number of bytes occupied by a len_t, i.e. the size of the encoded length in
the padding. *)
let len_length: maxed_hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16
(* Same thing, as a machine integer *)
inline_for_extraction
let len_len: a:maxed_hash_alg -> Tot (n:size_t{v n = len_length a}) = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul
(** Working state of the algorithms. *)
(* Internally, hash functions operate on a series of machine words. *)
inline_for_extraction
let word_t: hash_alg -> Tot inttype = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> U32
| SHA2_384 | SHA2_512 -> U64
| Blake2S -> U32
| Blake2B -> U64
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> U64
inline_for_extraction
let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4
inline_for_extraction
let word (a: hash_alg) = match a with
| Blake2S | Blake2B -> row a
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> uint_t (word_t a) SEC
(* In bytes. Should be: bytes_of_int (word_t a) *)
let word_length: hash_alg -> Tot nat = function
| MD5 | SHA1
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 8
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 8
| Blake2S -> 4
| Blake2B -> 8
let rate (a: keccak_alg): (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) =
match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088
(* Number of words for a block size *)
let block_word_length (a: hash_alg) =
match a with
| SHA3_224 -> normalize_term (rate SHA3_224 / 8 / 8)
| SHA3_256 -> normalize_term (rate SHA3_256 / 8 / 8)
| SHA3_384 -> normalize_term (rate SHA3_384 / 8 / 8)
| SHA3_512 -> normalize_term (rate SHA3_512 / 8 / 8)
| Shake128 -> normalize_term (rate Shake128 / 8 / 8)
| Shake256 -> normalize_term (rate Shake256 / 8 / 8)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| Blake2S
| Blake2B -> 16
(* Define the size block in bytes *)
let block_length a: nonzero =
let open FStar.Mul in
word_length a * block_word_length a
(* Number of words for intermediate hash, i.e. the working state. *)
inline_for_extraction
let state_word_length a =
match a with
| MD5 -> 4
| SHA1 -> 5
| Blake2S | Blake2B -> 4
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512 -> 8
inline_for_extraction
let extra_state a = match a with
| Blake2S | Blake2B -> n:nat { n % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
(* The working state *)
inline_for_extraction
let words_state a = lseq (word a) (state_word_length a)
(* Number of words for final hash *)
inline_for_extraction
let hash_word_length: a:md_alg -> Tot nat = function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8
(* Define the final hash length in bytes *)
let hash_length (a: hash_alg { not (is_shake a) }): Lib.IntTypes.(n:size_nat { n > 0 }) =
let open FStar.Mul in
if is_md a then
word_length a * hash_word_length a
else
match a with
| SHA3_224 -> 28
| SHA3_256 -> 32
| SHA3_384 -> 48
| SHA3_512 -> 64
| Blake2S -> 4 * 8
| Blake2B -> 8 * 8
(** Padding *)
(* Number of zeroes that should go into the padding *)
let pad0_length (a:md_alg) (len:nat): Tot (n:nat{(len + 1 + n + len_length a) % block_length a = 0}) =
(block_length a - (len + len_length a + 1)) % block_length a
(* Total length for the padding, a.k.a. the suffix length. *)
let pad_length (a: md_alg) (len: nat): Tot (n:nat { (len + n) % block_length a = 0 }) =
pad0_length a len + 1 + len_length a
(** Endian-ness *)
(* Define word based operators *)
let bytes_of_words: a:hash_alg{is_md a} -> Tot (#len:size_nat{FStar.Mul.(len * word_length a) <= max_size_t} -> s:lseq (word a) len -> Tot (lbytes FStar.Mul.(word_length a * len))) = function
| MD5 -> Lib.ByteSequence.uints_to_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_to_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_to_bytes_be #U64 #SEC | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 |
a: Spec.Hash.Definitions.hash_alg{Spec.Hash.Definitions.is_md a} ->
b:
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(Spec.Hash.Definitions.word_length a * len)
-> Lib.Sequence.lseq (Spec.Hash.Definitions.word a) len | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.Hash.Definitions.is_md",
"Lib.ByteSequence.uints_from_bytes_le",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.uints_from_bytes_be",
"Lib.IntTypes.U64",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply",
"Spec.Hash.Definitions.word_length",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Spec.Hash.Definitions.word"
] | [] | false | false | false | false | false | let words_of_bytes: a: hash_alg{is_md a}
-> Tot
(
#len: size_nat{FStar.Mul.(len * word_length a) <= max_size_t} ->
b: lbytes FStar.Mul.(word_length a * len)
-> Tot (lseq (word a) len)) =
| function
| MD5 -> Lib.ByteSequence.uints_from_bytes_le #U32 #SEC
| SHA1 | SHA2_224 | SHA2_256 -> Lib.ByteSequence.uints_from_bytes_be #U32 #SEC
| SHA2_384 | SHA2_512 -> Lib.ByteSequence.uints_from_bytes_be #U64 #SEC | false |
Options.fst | Options.makefile | val makefile:ref (option (valid_string valid_makefile)) | val makefile:ref (option (valid_string valid_makefile)) | let makefile : ref (option (valid_string valid_makefile)) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 70,
"end_line": 85,
"start_col": 0,
"start_line": 85
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_makefile)) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_makefile",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let makefile:ref (option (valid_string valid_makefile)) =
| alloc None | false |
Options.fst | Options.valid_check_hashes | val valid_check_hashes: string -> Tot bool | val valid_check_hashes: string -> Tot bool | let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 12,
"end_line": 101,
"start_col": 0,
"start_line": 96
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc [] | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_check_hashes: string -> Tot bool =
| function
| "weak" | "strong" | "inplace" -> true
| _ -> false | false |
Options.fst | Options.check_hashes | val check_hashes:ref (option (valid_string valid_check_hashes)) | val check_hashes:ref (option (valid_string valid_check_hashes)) | let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 78,
"end_line": 103,
"start_col": 0,
"start_line": 103
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_check_hashes)) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_check_hashes",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let check_hashes:ref (option (valid_string valid_check_hashes)) =
| alloc None | false |
Options.fst | Options.equate_types_list | val equate_types_list:ref (list (valid_string valid_equate_types)) | val equate_types_list:ref (list (valid_string valid_equate_types)) | let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc [] | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 79,
"end_line": 94,
"start_col": 0,
"start_line": 94
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (Prims.list (Options.valid_string Options.valid_equate_types)) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.list",
"Options.valid_string",
"Options.valid_equate_types",
"FStar.Heap.trivial_preorder",
"Prims.Nil",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let equate_types_list:ref (list (valid_string valid_equate_types)) =
| alloc [] | false |
Options.fst | Options.starts_with_capital | val starts_with_capital (s: string) : Tot bool | val starts_with_capital (s: string) : Tot bool | let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 22,
"start_col": 0,
"start_line": 18
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Prims.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.op_AmpAmp",
"Prims.op_GreaterThanOrEqual",
"FStar.String.length",
"FStar.String.compare",
"Prims.op_LessThanOrEqual",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.String.strlen",
"FStar.String.sub",
"Prims.bool"
] | [] | false | false | false | true | false | let starts_with_capital (s: string) : Tot bool =
| String.length s >= 1 &&
(let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0) | false |
Options.fst | Options.valid_equate_types | val valid_equate_types (str: string) : Tot bool | val valid_equate_types (str: string) : Tot bool | let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 17,
"end_line": 92,
"start_col": 0,
"start_line": 88
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | str: Prims.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.list",
"Prims.bool",
"FStar.String.split",
"Prims.Cons",
"FStar.String.char",
"Prims.Nil"
] | [] | false | false | false | true | false | let valid_equate_types (str: string) : Tot bool =
| let l = String.split [','] str in
match l with
| [m1 ; m2] -> true
| _ -> false | false |
Options.fst | Options.input_stream_binding | val input_stream_binding:ref (option (valid_string valid_input_stream_binding)) | val input_stream_binding:ref (option (valid_string valid_input_stream_binding)) | let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 94,
"end_line": 112,
"start_col": 0,
"start_line": 112
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_input_stream_binding
)) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_input_stream_binding",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let input_stream_binding:ref (option (valid_string valid_input_stream_binding)) =
| alloc None | false |
Options.fst | Options.valid_z3_test_mode | val valid_z3_test_mode: string -> Tot bool | val valid_z3_test_mode: string -> Tot bool | let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 12,
"end_line": 129,
"start_col": 0,
"start_line": 124
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_z3_test_mode: string -> Tot bool =
| function
| "pos" | "neg" | "all" -> true
| _ -> false | false |
Options.fst | Options.makefile_name | val makefile_name:ref (option vstring) | val makefile_name:ref (option vstring) | let makefile_name : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 53,
"end_line": 86,
"start_col": 0,
"start_line": 86
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let makefile_name:ref (option vstring) =
| alloc None | false |
Options.fst | Options.strip_suffix | val strip_suffix (fn: string) (sfx: string{ends_with fn sfx}) : string | val strip_suffix (fn: string) (sfx: string{ends_with fn sfx}) : string | let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx) | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 58,
"end_line": 40,
"start_col": 0,
"start_line": 38
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config" | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | fn: Prims.string -> sfx: Prims.string{Options.ends_with fn sfx} -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.b2t",
"Options.ends_with",
"FStar.String.sub",
"Prims.op_Subtraction",
"FStar.String.length"
] | [] | false | false | false | false | false | let strip_suffix (fn: string) (sfx: string{ends_with fn sfx}) : string =
| String.sub fn 0 (String.length fn - String.length sfx) | false |
Options.fst | Options.emit_smt_encoding | val emit_smt_encoding:ref bool | val emit_smt_encoding:ref bool | let emit_smt_encoding : ref bool = alloc false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 46,
"end_line": 118,
"start_col": 0,
"start_line": 118
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let emit_smt_encoding:ref bool =
| alloc false | false |
Options.fst | Options.z3_diff_test | val z3_diff_test:ref (option (valid_string valid_equate_types)) | val z3_diff_test:ref (option (valid_string valid_equate_types)) | let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 77,
"end_line": 120,
"start_col": 0,
"start_line": 120
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_equate_types)) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_equate_types",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let z3_diff_test:ref (option (valid_string valid_equate_types)) =
| alloc None | false |
Options.fst | Options.valid_input_stream_binding | val valid_input_stream_binding: string -> Tot bool | val valid_input_stream_binding: string -> Tot bool | let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 12,
"end_line": 110,
"start_col": 0,
"start_line": 105
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_input_stream_binding: string -> Tot bool =
| function
| "buffer" | "extern" | "static" -> true
| _ -> false | false |
Options.fst | Options.valid_makefile | val valid_makefile (str: string) : Tot bool | val valid_makefile (str: string) : Tot bool | let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 14,
"end_line": 83,
"start_col": 0,
"start_line": 79
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | str: Prims.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_makefile (str: string) : Tot bool =
| match str with
| "gmake" | "nmake" -> true
| _ -> false | false |
Options.fst | Options.z3_test | val z3_test:ref (option vstring) | val z3_test:ref (option vstring) | let z3_test : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 47,
"end_line": 122,
"start_col": 0,
"start_line": 122
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let z3_test:ref (option vstring) =
| alloc None | false |
Options.fst | Options.input_stream_include | val input_stream_include:ref (option vstring) | val input_stream_include:ref (option vstring) | let input_stream_include : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 60,
"end_line": 114,
"start_col": 0,
"start_line": 114
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let input_stream_include:ref (option vstring) =
| alloc None | false |
Options.fst | Options.z3_branch_depth | val z3_branch_depth:ref (option vstring) | val z3_branch_depth:ref (option vstring) | let z3_branch_depth : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 55,
"end_line": 139,
"start_col": 0,
"start_line": 139
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let z3_branch_depth:ref (option vstring) =
| alloc None | false |
Options.fst | Options.z3_witnesses | val z3_witnesses:ref (option vstring) | val z3_witnesses:ref (option vstring) | let z3_witnesses : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 52,
"end_line": 133,
"start_col": 0,
"start_line": 133
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let z3_witnesses:ref (option vstring) =
| alloc None | false |
Options.fst | Options.ends_with | val ends_with (s suffix: string) : bool | val ends_with (s suffix: string) : bool | let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix' | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 23,
"end_line": 30,
"start_col": 0,
"start_line": 24
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Prims.string -> suffix: Prims.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.op_BarBar",
"Prims.op_GreaterThan",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.b2t",
"Prims.nat",
"FStar.String.strlen",
"FStar.String.sub",
"Prims.op_Subtraction",
"FStar.String.length"
] | [] | false | false | false | true | false | let ends_with (s suffix: string) : bool =
| let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else
let suffix' = String.sub s (l - sl) sl in
suffix = suffix' | false |
Options.fst | Options.fstar_opt | val fstar_opt : Type0 | let fstar_opt = FStar.Getopt.opt & string | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 41,
"end_line": 159,
"start_col": 0,
"start_line": 159
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.tuple2",
"FStar.Getopt.opt",
"Prims.string"
] | [] | false | false | false | true | true | let fstar_opt =
| FStar.Getopt.opt & string | false |
|
Options.fst | Options.z3_options | val z3_options:ref (option vstring) | val z3_options:ref (option vstring) | let z3_options : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 50,
"end_line": 141,
"start_col": 0,
"start_line": 141
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let z3_options:ref (option vstring) =
| alloc None | false |
Options.fst | Options.z3_executable | val z3_executable:ref (option vstring) | val z3_executable:ref (option vstring) | let z3_executable : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 53,
"end_line": 135,
"start_col": 0,
"start_line": 135
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let z3_executable:ref (option vstring) =
| alloc None | false |
Options.fst | Options.test_checker | val test_checker:ref (option vstring) | val test_checker:ref (option vstring) | let test_checker : ref (option vstring) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 52,
"end_line": 137,
"start_col": 0,
"start_line": 137
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let test_checker:ref (option vstring) =
| alloc None | false |
Options.fst | Options.emit_output_types_defs | val emit_output_types_defs:ref bool | val emit_output_types_defs:ref bool | let emit_output_types_defs : ref bool = alloc true | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 50,
"end_line": 116,
"start_col": 0,
"start_line": 116
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let emit_output_types_defs:ref bool =
| alloc true | false |
Options.fst | Options.z3_test_mode | val z3_test_mode:ref (option (valid_string valid_z3_test_mode)) | val z3_test_mode:ref (option (valid_string valid_z3_test_mode)) | let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 78,
"end_line": 131,
"start_col": 0,
"start_line": 131
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_z3_test_mode)) | Prims.Tot | [
"total"
] | [] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.valid_string",
"Options.valid_z3_test_mode",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | false | false | false | true | false | let z3_test_mode:ref (option (valid_string valid_z3_test_mode)) =
| alloc None | false |
Options.fst | Options.negate_name | val negate_name (s: string) : Tot string | val negate_name (s: string) : Tot string | let negate_name (s: string) : Tot string = negate_string_gen s "no_" | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 68,
"end_line": 224,
"start_col": 0,
"start_line": 224
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Prims.string -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Options.negate_string_gen"
] | [] | false | false | false | true | false | let negate_name (s: string) : Tot string =
| negate_string_gen s "no_" | false |
Options.fst | Options.negate_description | val negate_description (s: string) : Tot string | val negate_description (s: string) : Tot string | let negate_description (s: string) : Tot string = negate_string_gen s "Do not" | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 78,
"end_line": 225,
"start_col": 0,
"start_line": 225
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_" | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Prims.string -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Options.negate_string_gen"
] | [] | false | false | false | true | false | let negate_description (s: string) : Tot string =
| negate_string_gen s "Do not" | false |
Options.fst | Options.name_is_negated | val name_is_negated (s: string) : Tot bool | val name_is_negated (s: string) : Tot bool | let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_" | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 73,
"end_line": 223,
"start_col": 0,
"start_line": 223
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Prims.string -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Options.string_starts_with",
"Prims.bool"
] | [] | false | false | false | true | false | let name_is_negated (s: string) : Tot bool =
| s `string_starts_with` "no_" | false |
Options.fst | Options.display_usage | val display_usage : unit -> ML unit | val display_usage : unit -> ML unit | let display_usage = display_usage_2 | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 35,
"end_line": 402,
"start_col": 0,
"start_line": 402
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list fstar_opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
((FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true)), desc);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false)), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None)), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
(
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := [])
),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption (('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0)), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdOption "test_checker" (OptStringOption "parser name" always_valid test_checker) "produce a test checker executable" [];
CmdFStarOption ((let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0)), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_branch_depth" (OptStringOption "nb" always_valid z3_branch_depth) "enumerate branch choices up to depth nb (default 0)" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_options" (OptStringOption "'options to z3'" always_valid z3_options) "command-line options to pass to z3 for test case generation (does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses per branch case (default 1)" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|copy_everparse_h|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options) | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 -> FStar.All.ML Prims.unit | FStar.All.ML | [
"ml"
] | [] | [
"Options.display_usage_2"
] | [] | false | true | false | false | false | let display_usage =
| display_usage_2 | false |
Options.fst | Options.compute_options | val compute_options (ignore: list string) : ML string | val compute_options (ignore: list string) : ML string | let compute_options = compute_options_2 | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 39,
"end_line": 404,
"start_col": 0,
"start_line": 404
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list fstar_opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
((FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true)), desc);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false)), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None)), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
(
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := [])
),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption (('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0)), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdOption "test_checker" (OptStringOption "parser name" always_valid test_checker) "produce a test checker executable" [];
CmdFStarOption ((let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0)), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_branch_depth" (OptStringOption "nb" always_valid z3_branch_depth) "enumerate branch choices up to depth nb (default 0)" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_options" (OptStringOption "'options to z3'" always_valid z3_options) "command-line options to pass to z3 for test case generation (does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses per branch case (default 1)" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|copy_everparse_h|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2 | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | ignore: Prims.list Prims.string -> FStar.All.ML Prims.string | FStar.All.ML | [
"ml"
] | [] | [
"Options.compute_options_2"
] | [] | false | true | false | false | false | let compute_options =
| compute_options_2 | false |
Options.fst | Options.debug_print_string | val debug_print_string (s:string) : ML unit | val debug_print_string (s:string) : ML unit | let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else () | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 9,
"end_line": 439,
"start_col": 0,
"start_line": 436
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list fstar_opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
((FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true)), desc);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false)), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None)), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
(
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := [])
),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption (('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0)), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdOption "test_checker" (OptStringOption "parser name" always_valid test_checker) "produce a test checker executable" [];
CmdFStarOption ((let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0)), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_branch_depth" (OptStringOption "nb" always_valid z3_branch_depth) "enumerate branch choices up to depth nb (default 0)" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_options" (OptStringOption "'options to z3'" always_valid z3_options) "command-line options to pass to z3 for test case generation (does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses per branch case (default 1)" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|copy_everparse_h|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline (List.Tot.map fst fstar_options) (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Prims.string -> FStar.All.ML Prims.unit | FStar.All.ML | [
"ml"
] | [] | [
"Prims.string",
"FStar.IO.print_string",
"Prims.unit",
"Prims.bool",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.debug"
] | [] | false | true | false | false | false | let debug_print_string (s: string) : ML unit =
| if !debug then FStar.IO.print_string s | false |
Options.fst | Options.get_cleanup | val get_cleanup : unit -> ML bool | val get_cleanup : unit -> ML bool | let get_cleanup () =
!cleanup | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 10,
"end_line": 453,
"start_col": 0,
"start_line": 452
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list fstar_opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
((FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true)), desc);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false)), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None)), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
(
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := [])
),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption (('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0)), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdOption "test_checker" (OptStringOption "parser name" always_valid test_checker) "produce a test checker executable" [];
CmdFStarOption ((let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0)), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_branch_depth" (OptStringOption "nb" always_valid z3_branch_depth) "enumerate branch choices up to depth nb (default 0)" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_options" (OptStringOption "'options to z3'" always_valid z3_options) "command-line options to pass to z3 for test case generation (does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses per branch case (default 1)" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|copy_everparse_h|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline (List.Tot.map fst fstar_options) (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 -> FStar.All.ML Prims.bool | FStar.All.ML | [
"ml"
] | [] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.cleanup"
] | [] | false | true | false | false | false | let get_cleanup () =
| !cleanup | false |
Options.fst | Options.get_no_everparse_h | val get_no_everparse_h : unit -> ML bool | val get_no_everparse_h : unit -> ML bool | let get_no_everparse_h () =
!no_copy_everparse_h | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 22,
"end_line": 459,
"start_col": 0,
"start_line": 458
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list fstar_opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
((FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true)), desc);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false)), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None)), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
(
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := [])
),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption (('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0)), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdOption "test_checker" (OptStringOption "parser name" always_valid test_checker) "produce a test checker executable" [];
CmdFStarOption ((let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0)), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_branch_depth" (OptStringOption "nb" always_valid z3_branch_depth) "enumerate branch choices up to depth nb (default 0)" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_options" (OptStringOption "'options to z3'" always_valid z3_options) "command-line options to pass to z3 for test case generation (does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses per branch case (default 1)" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|copy_everparse_h|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline (List.Tot.map fst fstar_options) (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 -> FStar.All.ML Prims.bool | FStar.All.ML | [
"ml"
] | [] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.no_copy_everparse_h"
] | [] | false | true | false | false | false | let get_no_everparse_h () =
| !no_copy_everparse_h | false |
Options.fst | Options.get_batch | val get_batch : unit -> ML bool | val get_batch : unit -> ML bool | let get_batch () =
!batch | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 8,
"end_line": 442,
"start_col": 0,
"start_line": 441
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list fstar_opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
((FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true)), desc);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false)), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None)), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
(
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := [])
),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption (('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0)), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdOption "test_checker" (OptStringOption "parser name" always_valid test_checker) "produce a test checker executable" [];
CmdFStarOption ((let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0)), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_branch_depth" (OptStringOption "nb" always_valid z3_branch_depth) "enumerate branch choices up to depth nb (default 0)" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_options" (OptStringOption "'options to z3'" always_valid z3_options) "command-line options to pass to z3 for test case generation (does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses per branch case (default 1)" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|copy_everparse_h|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline (List.Tot.map fst fstar_options) (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else () | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 -> FStar.All.ML Prims.bool | FStar.All.ML | [
"ml"
] | [] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.batch"
] | [] | false | true | false | false | false | let get_batch () =
| !batch | false |
Options.fst | Options.get_produce_c_from_existing_krml | val get_produce_c_from_existing_krml : unit -> ML bool | val get_produce_c_from_existing_krml : unit -> ML bool | let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 31,
"end_line": 492,
"start_col": 0,
"start_line": 491
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list fstar_opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
((FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true)), desc);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false)), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None)), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
(
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := [])
),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption (('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0)), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdOption "test_checker" (OptStringOption "parser name" always_valid test_checker) "produce a test checker executable" [];
CmdFStarOption ((let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0)), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_branch_depth" (OptStringOption "nb" always_valid z3_branch_depth) "enumerate branch choices up to depth nb (default 0)" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_options" (OptStringOption "'options to z3'" always_valid z3_options) "command-line options to pass to z3 for test case generation (does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses per branch case (default 1)" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|copy_everparse_h|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline (List.Tot.map fst fstar_options) (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch
let get_clang_format () =
!clang_format
let get_clang_format_executable () =
match !clang_format_executable with
| None -> ""
| Some s -> s
let get_cleanup () =
!cleanup
let get_skip_c_makefiles () =
!skip_c_makefiles
let get_no_everparse_h () =
!no_copy_everparse_h
let get_check_hashes () =
if !batch then match !check_hashes with
| None -> None
| Some "weak" -> Some WeakHashes
| Some "strong" -> Some StrongHashes
| Some "inplace" -> Some InplaceHashes
else None
let get_save_hashes () =
!save_hashes
let get_check_inplace_hashes () =
List.rev !inplace_hashes
let get_equate_types_list () =
List.map
(fun (x: valid_string valid_equate_types) ->
let [a; b] = String.split [','] x in (a, b)
)
!equate_types_list
let get_micro_step _ =
match !micro_step with
| None -> None
| Some "verify" -> Some MicroStepVerify
| Some "extract" -> Some MicroStepExtract
| Some "copy_clang_format" -> Some MicroStepCopyClangFormat
| Some "copy_everparse_h" -> Some MicroStepCopyEverParseH
| Some "emit_config" -> Some MicroStepEmitConfig | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 -> FStar.All.ML Prims.bool | FStar.All.ML | [
"ml"
] | [] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.produce_c_from_existing_krml"
] | [] | false | true | false | false | false | let get_produce_c_from_existing_krml _ =
| !produce_c_from_existing_krml | false |
Options.fst | Options.get_clang_format | val get_clang_format : unit -> ML bool | val get_clang_format : unit -> ML bool | let get_clang_format () =
!clang_format | {
"file_name": "src/3d/Options.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 15,
"end_line": 445,
"start_col": 0,
"start_line": 444
} | module Options
open HashingOptions
open FStar.All
open FStar.ST
module U8 = FStar.UInt8
module OS = OS
#push-options "--warn_error -272" //top-level effects are okay
inline_for_extraction
let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true })
let always_valid (_: string) : Tot bool = true
let starts_with_capital (s: string) : Tot bool =
String.length s >= 1 &&
begin let first = String.sub s 0 1 in
String.compare first "A" >= 0 && String.compare first "Z" <= 0
end
let ends_with (s:string) (suffix:string) : bool =
let l = String.length s in
let sl = String.length suffix in
if sl > l || sl = 0
then false
else let suffix' = String.sub s (l - sl) sl in
suffix = suffix'
let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config"
let strip_suffix (fn:string) (sfx:string { ends_with fn sfx })
: string
= String.sub fn 0 (String.length fn - String.length sfx)
inline_for_extraction
let vstring = valid_string always_valid
(* NOTE: default arguments here MUST be set to false, [] or None *)
let arg0 : ref (option vstring) = alloc None
let add_include : ref (list vstring) = alloc []
let batch : ref bool = alloc false
let clang_format : ref bool = alloc false
let clang_format_executable : ref (option vstring) = alloc None
let cleanup : ref bool = alloc false
let config_file : ref (option (valid_string check_config_file_name)) = alloc None
let debug : ref bool = alloc false
let inplace_hashes : ref (list vstring) = alloc []
let input_file : ref (list string) = alloc []
let json : ref bool = alloc false
let no_copy_everparse_h : ref bool = alloc false
let output_dir : ref (option vstring) = alloc None
let save_hashes : ref bool = alloc false
let save_z3_transcript: ref (option vstring) = alloc None
let skip_c_makefiles : ref bool = alloc false
let skip_deps: ref bool = alloc false
let skip_o_rules: ref bool = alloc false
let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "copy_everparse_h"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None
let produce_c_from_existing_krml : ref bool = alloc false
let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false
let makefile : ref (option (valid_string valid_makefile)) = alloc None
let makefile_name : ref (option vstring) = alloc None
let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false
let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc []
let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false
let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None
let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false
let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None
let input_stream_include : ref (option vstring) = alloc None
let emit_output_types_defs : ref bool = alloc true
let emit_smt_encoding : ref bool = alloc false
let z3_diff_test: ref (option (valid_string valid_equate_types)) = alloc None
let z3_test : ref (option vstring) = alloc None
let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false
let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None
let z3_witnesses : ref (option vstring) = alloc None
let z3_executable : ref (option vstring) = alloc None
let test_checker : ref (option vstring) = alloc None
let z3_branch_depth : ref (option vstring) = alloc None
let z3_options : ref (option vstring) = alloc None
noeq
type cmd_option_kind =
| OptBool:
(v: ref bool) ->
cmd_option_kind
| OptStringOption:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (option (valid_string valid))) ->
cmd_option_kind
| OptList:
(arg_desc: string) ->
(valid: (string -> Tot bool)) ->
(v: ref (list (valid_string valid))) ->
cmd_option_kind
let fstar_opt = FStar.Getopt.opt & string
noeq
type cmd_option
= | CmdOption:
(name: string) ->
(kind: cmd_option_kind) ->
(desc: string) ->
(implies: list string) (* name of OptBool to set to true *) ->
cmd_option
| CmdFStarOption of fstar_opt
let cmd_option_name (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, name', _), _)
| CmdOption name' _ _ _
-> name'
let rec find_cmd_option (name: string) (l: list cmd_option): Tot (option cmd_option) = match l with
| [] -> None
| a :: q ->
if name = cmd_option_name a then Some a else find_cmd_option name q
let cmd_option_description (a: cmd_option) : Tot string =
match a with
| CmdOption _ _ desc _
| CmdFStarOption (_, desc) ->
desc
let cmd_option_arg_desc (a: cmd_option) : Tot string =
match a with
| CmdFStarOption ((_, _, arg), _) ->
begin match arg with
| FStar.Getopt.OneArg (_, argdesc) -> argdesc
| _ -> ""
end
| CmdOption _ kind _ _ ->
begin match kind with
| OptStringOption argdesc _ _
| OptList argdesc _ _
-> argdesc
| _ -> ""
end
let set_implies (options: ref (list cmd_option)) (implies: list string) : ML unit =
List.iter
(fun name ->
match find_cmd_option name !options with
| Some (CmdOption _ (OptBool x) _ _) -> x := true
| _ -> ()
)
implies
let string_starts_with (big small: string) : Tot bool =
let small_len = String.length small in
if String.length big < small_len
then false
else String.sub big 0 small_len = small
let negate_string_gen (s: string) (negation: string) =
if s `string_starts_with` negation
then String.sub s (String.length negation) (String.length s - String.length negation)
else negation ^ s
let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_"
let negate_name (s: string) : Tot string = negate_string_gen s "no_"
let negate_description (s: string) : Tot string = negate_string_gen s "Do not"
let fstar_options_of_cmd_option
(options: ref (list cmd_option))
(o: cmd_option)
: Tot (list fstar_opt)
= match o with
| CmdFStarOption f -> [f]
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
[
((FStar.Getopt.noshort, name, FStar.Getopt.ZeroArgs (fun _ -> set_implies options implies; v := true)), desc);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := false)), negate_description desc);
]
| OptStringOption arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := Some x
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
((FStar.Getopt.noshort, negate_name name, FStar.Getopt.ZeroArgs (fun _ -> v := None)), negate_description desc)
]
| OptList arg_desc valid v ->
[
(
(
FStar.Getopt.noshort, name,
FStar.Getopt.OneArg (
(fun (x: string) ->
if valid x
then begin
set_implies options implies;
v := x :: !v
end else
failwith (Printf.sprintf "Bad argument to %s: got %s, expected %s" name x arg_desc)
),
arg_desc
)
),
desc
);
(
(
FStar.Getopt.noshort, negate_name name,
FStar.Getopt.ZeroArgs (fun _ -> v := [])
),
desc
);
]
end
let compute_current_options (options: ref (list cmd_option)) (ignore: list string) : ML string =
(* we would like to output a normalized sequence of options so that its semantics does not depend on whether any other options are prepended (i.e. whether 3d is run from 3d or from everparse.cmd or from everparse.sh *)
(* first print the values of current options except untoggled boolean options *)
let print (msg: string) (opt: cmd_option) : ML string =
if List.Tot.mem (cmd_option_name opt) ignore
then msg
else
match opt with
| CmdOption name kind desc implies ->
begin match kind with
| OptBool v ->
if !v
then Printf.sprintf "%s --%s" msg name
else msg
| OptStringOption _ _ v ->
begin match !v with
| None -> Printf.sprintf "%s --%s" msg (negate_name name)
| Some v -> Printf.sprintf "%s --%s %s" msg name v
end
| OptList _ _ v ->
let v = !v in
let msg = Printf.sprintf "%s --%s" msg (negate_name name) in
let app (msg: string) (s: string) = Printf.sprintf "%s --%s %s" msg name s in
List.Tot.fold_left app msg (List.Tot.rev v) (* list was accumulated as a fifo *)
end
| _ -> msg
in
let msg = List.fold_left print "" !options in
(* then print the untoggled boolean options *)
let print_untoggle (msg: string) (opt: cmd_option) : ML string =
match opt with
| CmdOption name (OptBool v) _ _ ->
if (if not (List.Tot.mem name ignore) then not !v else false)
then Printf.sprintf "%s --%s" msg (negate_name name)
else msg
| _ -> msg
in
List.fold_left print_untoggle msg !options
let get_arg0 () : ML string =
match !arg0 with
| None -> "3d"
| Some v -> v
let display_usage_1 (options: ref (list cmd_option)) : ML unit =
FStar.IO.print_string "EverParse/3d: verified data validation with dependent data descriptions\n";
FStar.IO.print_string "\n";
FStar.IO.print_string (Printf.sprintf "Usage: %s [options] path_to_input_file1.3d path_to_input_file2.3d ... \n" (get_arg0 ()));
FStar.IO.print_string "\n";
FStar.IO.print_string "Options:\n";
List.iter
(fun x ->
let m = cmd_option_name x in
let desc = cmd_option_description x in
let argdesc = cmd_option_arg_desc x in
let argdesc = if argdesc = "" then "" else Printf.sprintf " <%s>" argdesc in
let negate = if CmdOption? x then Printf.sprintf " (opposite is --%s)" (negate_name m) else "" in
let visible = not (m `string_starts_with` "__") in
if visible then FStar.IO.print_string (Printf.sprintf "--%s%s%s\n\t%s\n" m argdesc negate desc)
)
!options
;
FStar.IO.print_string (Printf.sprintf "\nCurrent options are:%s\n" (compute_current_options options []))
let (display_usage_2, compute_options_2, fstar_options) =
let options : ref (list cmd_option) = alloc [] in
let display_usage () = display_usage_1 options in
let compute_options = compute_current_options options in
options := [
CmdOption "add_include" (OptList "<include.h>|\"include.h\"" always_valid add_include) "Prepend #include ... to generated .c/.h files" [];
CmdOption "batch" (OptBool batch) "Verify the generated F* code and extract C code" [];
CmdOption "check_hashes" (OptStringOption "weak|strong|inplace" valid_check_hashes check_hashes) "Check hashes" ["batch"];
CmdOption "check_inplace_hash" (OptList "file.3d=file.h" always_valid inplace_hashes) "Check hashes stored in one .h/.c file" [];
CmdOption "clang_format" (OptBool clang_format) "Call clang-format on extracted .c/.h files (--batch only)" ["batch"];
CmdOption "clang_format_executable" (OptStringOption "clang-format full path" always_valid clang_format_executable) "Set the path to clang-format if not reachable through PATH" ["batch"; "clang_format"];
CmdOption "cleanup" (OptBool cleanup) "Remove *.fst*, *.krml and krml-args.rsp (--batch only)" [];
CmdOption "config" (OptStringOption "config file" check_config_file_name config_file) "The name of a JSON formatted file containing configuration options" [];
CmdOption "emit_output_types_defs" (OptBool emit_output_types_defs) "Emit definitions of output types in a .h file" [];
CmdOption "emit_smt_encoding" (OptBool emit_smt_encoding) "Emit an SMT encoding of parser specifications" [];
CmdOption "input_stream" (OptStringOption "buffer|extern|static" valid_input_stream_binding input_stream_binding) "Input stream binding (default buffer)" [];
CmdOption "input_stream_include" (OptStringOption ".h file" always_valid input_stream_include) "Include file defining the EverParseInputStreamBase type (only for --input_stream extern or static)" [];
CmdOption "no_copy_everparse_h" (OptBool no_copy_everparse_h) "Do not Copy EverParse.h (--batch only)" [];
CmdOption "debug" (OptBool debug) "Emit a lot of debugging output" [];
CmdFStarOption (('h', "help", FStar.Getopt.ZeroArgs (fun _ -> display_usage (); exit 0)), "Show this help message");
CmdOption "json" (OptBool json) "Dump the AST in JSON format" [];
CmdOption "makefile" (OptStringOption "gmake|nmake" valid_makefile makefile) "Do not produce anything, other than a Makefile to produce everything" [];
CmdOption "makefile_name" (OptStringOption "some file name" always_valid makefile_name) "Name of the Makefile to produce (with --makefile, default <output directory>/EverParse.Makefile" [];
CmdOption "odir" (OptStringOption "output directory" always_valid output_dir) "output directory (default '.'); writes <module_name>.fst and <module_name>_wrapper.c to the output directory" [];
CmdOption "save_hashes" (OptBool save_hashes) "Save hashes" [];
CmdOption "save_z3_transcript" (OptStringOption "some file name" always_valid save_z3_transcript) "Save the Z3 transcript (input and output) to a file" [];
CmdOption "skip_c_makefiles" (OptBool skip_c_makefiles) "Do not Generate Makefile.basic, Makefile.include" [];
CmdOption "skip_o_rules" (OptBool skip_o_rules) "With --makefile, do not generate rules for .o files" [];
CmdOption "test_checker" (OptStringOption "parser name" always_valid test_checker) "produce a test checker executable" [];
CmdFStarOption ((let open FStar.Getopt in noshort, "version", ZeroArgs (fun _ -> FStar.IO.print_string (Printf.sprintf "EverParse/3d %s\nCopyright 2018, 2019, 2020 Microsoft Corporation\n" Version.everparse_version); exit 0)), "Show this version of EverParse");
CmdOption "equate_types" (OptList "an argument of the form A,B, to generate asserts of the form (A.t == B.t)" valid_equate_types equate_types_list) "Takes an argument of the form A,B and then for each entrypoint definition in B, it generates an assert (A.t == B.t) in the B.Types file, useful when refactoring specs, you can provide multiple equate_types on the command line" [];
CmdOption "z3_branch_depth" (OptStringOption "nb" always_valid z3_branch_depth) "enumerate branch choices up to depth nb (default 0)" [];
CmdOption "z3_diff_test" (OptStringOption "parser1,parser2" valid_equate_types z3_diff_test) "produce differential tests for two parsers" [];
CmdOption "z3_executable" (OptStringOption "path/to/z3" always_valid z3_executable) "z3 executable for test case generation (default `z3`; does not affect verification of generated F* code)" [];
CmdOption "z3_options" (OptStringOption "'options to z3'" always_valid z3_options) "command-line options to pass to z3 for test case generation (does not affect verification of generated F* code)" [];
CmdOption "z3_test" (OptStringOption "parser name" always_valid z3_test) "produce positive and/or negative test cases for a given parser" [];
CmdOption "z3_test_mode" (OptStringOption "pos|neg|all" valid_z3_test_mode z3_test_mode) "produce positive, negative, or all kinds of test cases (default all)" [];
CmdOption "z3_witnesses" (OptStringOption "nb" always_valid z3_witnesses) "ask for nb distinct test witnesses per branch case (default 1)" [];
CmdOption "__arg0" (OptStringOption "executable name" always_valid arg0) "executable name to use for the help message" [];
CmdOption "__micro_step" (OptStringOption "verify|extract|copy_clang_format|copy_everparse_h|emit_config" valid_micro_step micro_step) "micro step" [];
CmdOption "__produce_c_from_existing_krml" (OptBool produce_c_from_existing_krml) "produce C from .krml files" [];
CmdOption "__skip_deps" (OptBool skip_deps) "skip dependency analysis, assume all dependencies are specified on the command line" [];
];
let fstar_options =
List.Tot.concatMap (fstar_options_of_cmd_option options) !options
in
(display_usage, compute_options, fstar_options)
let display_usage = display_usage_2
let compute_options = compute_options_2
let parse_cmd_line () : ML (list string) =
let open FStar.Getopt in
let res = FStar.Getopt.parse_cmdline (List.Tot.map fst fstar_options) (fun file -> input_file := file :: !input_file; Success) in
match res with
| Success -> !input_file
| Help -> display_usage(); exit 0
| Error s -> FStar.IO.print_string s; exit 1
| _ -> exit 2
let split_3d_file_name fn =
let fn = OS.basename fn in
if OS.extension fn = ".3d"
then Some (OS.remove_extension fn)
else None
let get_file_name mname = mname ^ ".3d"
let get_module_name (file: string) =
match split_3d_file_name file with
| Some nm ->
if starts_with_capital nm
then nm
else failwith (Printf.sprintf "Input file name %s must start with a capital letter" file)
| None -> failwith (Printf.sprintf "Input file name %s must end with .3d" file)
let get_output_dir () =
match !output_dir with
| None -> "."
| Some s -> s
let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else ()
let get_batch () =
!batch | {
"checked_file": "/",
"dependencies": [
"Version.fsti.checked",
"prims.fst.checked",
"OS.fsti.checked",
"HashingOptions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Getopt.fsti.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Options.fst"
} | [
{
"abbrev": true,
"full_module": "OS",
"short_module": "OS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "HashingOptions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 -> FStar.All.ML Prims.bool | FStar.All.ML | [
"ml"
] | [] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.clang_format"
] | [] | false | true | false | false | false | let get_clang_format () =
| !clang_format | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.