effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | [
{
"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
}
] | false | let is_md = function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false | let is_md = | false | null | false | function
| MD5 | SHA1 | SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.bool"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val is_md : _: Spec.Hash.Definitions.hash_alg -> Prims.bool | [] | Spec.Hash.Definitions.is_md | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> Prims.bool | {
"end_col": 14,
"end_line": 75,
"start_col": 12,
"start_line": 73
} |
|
Prims.Tot | [
{
"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
}
] | false | let md_alg = a:hash_alg { is_md a } | let md_alg = | false | null | false | a: hash_alg{is_md a} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.Hash.Definitions.is_md"
] | [] | 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 } | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val md_alg : Type0 | [] | Spec.Hash.Definitions.md_alg | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 35,
"end_line": 80,
"start_col": 13,
"start_line": 80
} |
|
Prims.Tot | [
{
"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
}
] | false | let is_shake = function
| Shake128 | Shake256 -> true
| _ -> false | let is_shake = | false | null | false | function
| Shake128 | Shake256 -> true
| _ -> false | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.bool"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val is_shake : _: Spec.Hash.Definitions.hash_alg -> Prims.bool | [] | Spec.Hash.Definitions.is_shake | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> Prims.bool | {
"end_col": 14,
"end_line": 65,
"start_col": 15,
"start_line": 63
} |
|
Prims.Tot | [
{
"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
}
] | false | let keccak_alg = a:hash_alg { is_keccak a } | let keccak_alg = | false | null | false | a: hash_alg{is_keccak a} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.Hash.Definitions.is_keccak"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val keccak_alg : Type0 | [] | Spec.Hash.Definitions.keccak_alg | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 43,
"end_line": 78,
"start_col": 17,
"start_line": 78
} |
|
Prims.Tot | [
{
"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
}
] | false | let bytes_blocks a =
l:bytes { Seq.length l % block_length a = 0 } | let bytes_blocks a = | false | null | false | l: bytes{Seq.length l % block_length a = 0} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.block_length"
] | [] | 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. *) | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val bytes_blocks : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Spec.Hash.Definitions.bytes_blocks | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 47,
"end_line": 308,
"start_col": 2,
"start_line": 308
} |
|
Prims.Tot | [
{
"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
}
] | false | let maxed_hash_alg = a:hash_alg { Some? (max_input_length a) } | let maxed_hash_alg = | false | null | false | a: hash_alg{Some? (max_input_length a)} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"Prims.pos",
"Spec.Hash.Definitions.max_input_length"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val maxed_hash_alg : Type0 | [] | Spec.Hash.Definitions.maxed_hash_alg | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 62,
"end_line": 107,
"start_col": 21,
"start_line": 107
} |
|
Prims.Tot | [
{
"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
}
] | false | let is_blake = function
| Blake2S | Blake2B -> true
| _ -> false | let is_blake = | false | null | false | function
| Blake2S | Blake2B -> true
| _ -> false | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.bool"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val is_blake : _: Spec.Hash.Definitions.hash_alg -> Prims.bool | [] | Spec.Hash.Definitions.is_blake | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> Prims.bool | {
"end_col": 14,
"end_line": 70,
"start_col": 15,
"start_line": 68
} |
|
Prims.Tot | [
{
"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
}
] | false | let init_t (a: hash_alg) = words_state a | let init_t (a: hash_alg) = | false | null | false | words_state a | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.words_state"
] | [] | 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 *) | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val init_t : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Spec.Hash.Definitions.init_t | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 40,
"end_line": 331,
"start_col": 27,
"start_line": 331
} |
|
Prims.Tot | [
{
"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
}
] | false | let is_sha2 = function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false | let is_sha2 = | false | null | false | function
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.bool"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val is_sha2 : _: Spec.Hash.Definitions.hash_alg -> Prims.bool | [] | Spec.Hash.Definitions.is_sha2 | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> Prims.bool | {
"end_col": 14,
"end_line": 55,
"start_col": 14,
"start_line": 53
} |
|
Prims.Tot | [
{
"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
}
] | false | let is_keccak = function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false | let is_keccak = | false | null | false | function
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> true
| _ -> false | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.bool"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val is_keccak : _: Spec.Hash.Definitions.hash_alg -> Prims.bool | [] | Spec.Hash.Definitions.is_keccak | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> Prims.bool | {
"end_col": 14,
"end_line": 60,
"start_col": 16,
"start_line": 58
} |
|
Prims.Tot | [
{
"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
}
] | false | let fixed_len_alg = a:hash_alg { not (is_shake a) } | let fixed_len_alg = | false | null | false | a: hash_alg{not (is_shake a)} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Prims.op_Negation",
"Spec.Hash.Definitions.is_shake"
] | [] | 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 } | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val fixed_len_alg : Type0 | [] | Spec.Hash.Definitions.fixed_len_alg | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 51,
"end_line": 81,
"start_col": 20,
"start_line": 81
} |
|
Prims.Tot | [
{
"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
}
] | false | let sha2_alg = a:hash_alg { is_sha2 a } | let sha2_alg = | false | null | false | a: hash_alg{is_sha2 a} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.Hash.Definitions.is_sha2"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val sha2_alg : Type0 | [] | Spec.Hash.Definitions.sha2_alg | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 39,
"end_line": 77,
"start_col": 15,
"start_line": 77
} |
|
Prims.Tot | [
{
"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
}
] | false | let blake_alg = a:hash_alg { is_blake a } | let blake_alg = | false | null | false | a: hash_alg{is_blake a} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.Hash.Definitions.is_blake"
] | [] | 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 } | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val blake_alg : Type0 | [] | Spec.Hash.Definitions.blake_alg | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 41,
"end_line": 79,
"start_col": 16,
"start_line": 79
} |
|
Prims.Tot | [
{
"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
}
] | false | let finish_t (a: hash_alg) =
h:words_state a ->
l: output_length a ->
bytes_hash' a l | let finish_t (a: hash_alg) = | false | null | false | h: words_state a -> l: output_length a -> bytes_hash' a l | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.output_length",
"Spec.Hash.Definitions.bytes_hash'"
] | [] | 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 } | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val finish_t : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Spec.Hash.Definitions.finish_t | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 17,
"end_line": 350,
"start_col": 2,
"start_line": 348
} |
|
Prims.Tot | [
{
"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
}
] | false | 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 } | let pad_t (a: md_alg) = | false | null | false | l: nat{l `less_than_max_input_length` a} -> b: bytes{(Seq.length b + l) % block_length a = 0} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val pad_t : a: Spec.Hash.Definitions.md_alg -> Type0 | [] | Spec.Hash.Definitions.pad_t | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.md_alg -> Type0 | {
"end_col": 53,
"end_line": 345,
"start_col": 2,
"start_line": 344
} |
|
Prims.Tot | [
{
"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
}
] | false | let update_t (a: md_alg) =
h:words_state a ->
l:bytes { Seq.length l = block_length a } ->
words_state a | let update_t (a: md_alg) = | false | null | false | h: words_state a -> l: bytes{Seq.length l = block_length a} -> words_state a | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val update_t : a: Spec.Hash.Definitions.md_alg -> Type0 | [] | Spec.Hash.Definitions.update_t | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.md_alg -> Type0 | {
"end_col": 15,
"end_line": 336,
"start_col": 2,
"start_line": 334
} |
|
Prims.Tot | [
{
"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
}
] | 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 | let state_word_length a = | false | null | false | 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": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.int"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val state_word_length : a: Spec.Hash.Definitions.hash_alg -> Prims.int | [] | Spec.Hash.Definitions.state_word_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Prims.int | {
"end_col": 28,
"end_line": 235,
"start_col": 2,
"start_line": 229
} |
|
Prims.Tot | [
{
"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
}
] | false | let bytes_block a =
l:bytes { Seq.length l = block_length a } | let bytes_block a = | false | null | false | l: bytes{Seq.length l = block_length a} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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. *) | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val bytes_block : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Spec.Hash.Definitions.bytes_block | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 43,
"end_line": 304,
"start_col": 2,
"start_line": 304
} |
|
Prims.Tot | [
{
"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
}
] | false | let to_blake_alg (a:blake_alg) = match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B | let to_blake_alg (a: blake_alg) = | false | null | false | match a with
| Blake2S -> Spec.Blake2.Blake2S
| Blake2B -> Spec.Blake2.Blake2B | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.blake_alg",
"Spec.Blake2.Blake2S",
"Spec.Blake2.Blake2B",
"Spec.Blake2.alg"
] | [] | 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) } | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val to_blake_alg : a: Spec.Hash.Definitions.blake_alg -> Spec.Blake2.alg | [] | Spec.Hash.Definitions.to_blake_alg | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.blake_alg -> Spec.Blake2.alg | {
"end_col": 34,
"end_line": 86,
"start_col": 33,
"start_line": 84
} |
|
Prims.Tot | [
{
"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
}
] | false | let to_hash_alg (a : Spec.Blake2.alg) =
match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B | let to_hash_alg (a: Spec.Blake2.alg) = | false | null | false | match a with
| Spec.Blake2.Blake2S -> Blake2S
| Spec.Blake2.Blake2B -> Blake2B | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Blake2.alg",
"Spec.Hash.Definitions.Blake2S",
"Spec.Hash.Definitions.Blake2B",
"Spec.Hash.Definitions.hash_alg"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val to_hash_alg : a: Spec.Blake2.alg -> Spec.Hash.Definitions.hash_alg | [] | Spec.Hash.Definitions.to_hash_alg | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Blake2.alg -> Spec.Hash.Definitions.hash_alg | {
"end_col": 34,
"end_line": 92,
"start_col": 2,
"start_line": 90
} |
|
Prims.Tot | val word_t: hash_alg -> Tot inttype | [
{
"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
}
] | 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 | val word_t: hash_alg -> Tot inttype
let word_t: hash_alg -> Tot inttype = | false | null | false | 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": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.inttype"
] | [] | 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. *) | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val word_t: hash_alg -> Tot inttype | [] | Spec.Hash.Definitions.word_t | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> Lib.IntTypes.inttype | {
"end_col": 74,
"end_line": 174,
"start_col": 38,
"start_line": 168
} |
Prims.Tot | val len_length: maxed_hash_alg -> Tot nat | [
{
"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
}
] | 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 | val len_length: maxed_hash_alg -> Tot nat
let len_length: maxed_hash_alg -> Tot nat = | false | null | false | function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8
| SHA2_384 | SHA2_512 -> 16
| Blake2S -> 8
| Blake2B -> 16 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.maxed_hash_alg",
"Prims.nat"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val len_length: maxed_hash_alg -> Tot nat | [] | Spec.Hash.Definitions.len_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.maxed_hash_alg -> Prims.nat | {
"end_col": 17,
"end_line": 154,
"start_col": 44,
"start_line": 149
} |
Prims.Tot | [
{
"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
}
] | false | 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 | let extra_state a = | false | null | false | 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 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val extra_state : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Spec.Hash.Definitions.extra_state | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 75,
"end_line": 243,
"start_col": 20,
"start_line": 238
} |
|
Prims.Tot | [
{
"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
}
] | false | let words_state a = lseq (word a) (state_word_length a) | let words_state a = | false | null | false | lseq (word a) (state_word_length a) | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Lib.Sequence.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.state_word_length"
] | [] | 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 *) | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val words_state : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Spec.Hash.Definitions.words_state | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 55,
"end_line": 247,
"start_col": 20,
"start_line": 247
} |
|
Prims.Tot | [
{
"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
}
] | 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 | let nat_to_len (a: maxed_hash_alg) (n: nat{n <= maxint (len_int_type a)}) = | false | null | false | mk_int #(len_int_type a) #PUB n | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | 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)}
-> u37:
Lib.IntTypes.int_t (Spec.Hash.Definitions.len_int_type a) Lib.IntTypes.PUB
{Lib.IntTypes.v u37 == n} | [] | Spec.Hash.Definitions.nat_to_len | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.maxed_hash_alg ->
n: Prims.nat{n <= Lib.IntTypes.maxint (Spec.Hash.Definitions.len_int_type a)}
-> u37:
Lib.IntTypes.int_t (Spec.Hash.Definitions.len_int_type a) Lib.IntTypes.PUB
{Lib.IntTypes.v u37 == n} | {
"end_col": 34,
"end_line": 127,
"start_col": 2,
"start_line": 127
} |
|
Prims.Tot | [
{
"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
}
] | false | let bytes_hash a =
b:bytes { Seq.length b = hash_length a } | let bytes_hash a = | false | null | false | b: bytes{Seq.length b = hash_length a} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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). *) | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | val bytes_hash : a: Spec.Hash.Definitions.hash_alg{Prims.op_Negation (Spec.Hash.Definitions.is_shake a)} -> Type0 | [] | Spec.Hash.Definitions.bytes_hash | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg{Prims.op_Negation (Spec.Hash.Definitions.is_shake a)} -> Type0 | {
"end_col": 42,
"end_line": 324,
"start_col": 2,
"start_line": 324
} |
|
Prims.Tot | val word_length: hash_alg -> Tot nat | [
{
"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
}
] | 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 | val word_length: hash_alg -> Tot nat
let word_length: hash_alg -> Tot nat = | false | null | false | 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": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.nat"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val word_length: hash_alg -> Tot nat | [] | Spec.Hash.Definitions.word_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> Prims.nat | {
"end_col": 16,
"end_line": 194,
"start_col": 39,
"start_line": 188
} |
Prims.Tot | val len_int_type: maxed_hash_alg -> inttype | [
{
"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
}
] | false | 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 | val len_int_type: maxed_hash_alg -> inttype
let len_int_type: maxed_hash_alg -> inttype = | false | null | false | function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> U64
| SHA2_384 | SHA2_512 -> U128
| Blake2S -> U64
| Blake2B -> U128 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.maxed_hash_alg",
"Lib.IntTypes.U64",
"Lib.IntTypes.U128",
"Lib.IntTypes.inttype"
] | [] | 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. *) | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val len_int_type: maxed_hash_alg -> inttype | [] | Spec.Hash.Definitions.len_int_type | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.maxed_hash_alg -> Lib.IntTypes.inttype | {
"end_col": 19,
"end_line": 123,
"start_col": 46,
"start_line": 118
} |
Prims.Tot | [
{
"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
}
] | false | 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 | let word (a: hash_alg) = | false | null | false | 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": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.row",
"Lib.IntTypes.uint_t",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.SEC"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val word : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Spec.Hash.Definitions.word | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 92,
"end_line": 185,
"start_col": 25,
"start_line": 180
} |
|
Prims.Tot | [
{
"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
}
] | false | let bytes_hash' a l =
b:bytes { Seq.length b = hash_length' a l } | let bytes_hash' a l = | false | null | false | b: bytes{Seq.length b = hash_length' a l} | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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'"
] | [] | 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 } | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | val bytes_hash' : a: Spec.Hash.Definitions.hash_alg -> l: Spec.Hash.Definitions.output_length a -> Type0 | [] | Spec.Hash.Definitions.bytes_hash' | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> l: Spec.Hash.Definitions.output_length a -> Type0 | {
"end_col": 45,
"end_line": 327,
"start_col": 2,
"start_line": 327
} |
|
Prims.Tot | [
{
"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
}
] | false | let row (a:blake_alg) = lseq (uint_t (word_t a) SEC) 4 | let row (a: blake_alg) = | false | null | false | lseq (uint_t (word_t a) SEC) 4 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.blake_alg",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint_t",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.SEC"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val row : a: Spec.Hash.Definitions.blake_alg -> Type0 | [] | Spec.Hash.Definitions.row | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.blake_alg -> Type0 | {
"end_col": 54,
"end_line": 177,
"start_col": 24,
"start_line": 177
} |
|
Prims.Tot | [
{
"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
}
] | false | let less_than_max_input_length l a =
match max_input_length a with
| Some max -> l <= max
| None -> true | let less_than_max_input_length l a = | false | null | false | match max_input_length a with
| Some max -> l <= max
| None -> true | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Prims.int",
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.max_input_length",
"Prims.pos",
"Prims.op_LessThanOrEqual",
"Prims.bool"
] | [] | 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 | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val less_than_max_input_length : l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool | [] | Spec.Hash.Definitions.less_than_max_input_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool | {
"end_col": 16,
"end_line": 341,
"start_col": 2,
"start_line": 339
} |
|
Prims.Tot | [
{
"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
}
] | 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 | let block_word_length (a: hash_alg) = | false | null | false | 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 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 *) | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val block_word_length : a: Spec.Hash.Definitions.hash_alg -> Prims.int | [] | Spec.Hash.Definitions.block_word_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Prims.int | {
"end_col": 17,
"end_line": 218,
"start_col": 2,
"start_line": 207
} |
|
Prims.Tot | val hash_word_length (a: md_alg) : Tot nat | [
{
"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
}
] | 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 | val hash_word_length (a: md_alg) : Tot nat
let hash_word_length: a: md_alg -> Tot nat = | false | null | false | function
| MD5 -> 4
| SHA1 -> 5
| SHA2_224 -> 7
| SHA2_256 -> 8
| SHA2_384 -> 6
| SHA2_512 -> 8 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.md_alg",
"Prims.nat"
] | [] | 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 *) | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val hash_word_length (a: md_alg) : Tot nat | [] | Spec.Hash.Definitions.hash_word_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.md_alg -> Prims.nat | {
"end_col": 17,
"end_line": 257,
"start_col": 44,
"start_line": 251
} |
Prims.Tot | [
{
"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
}
] | false | 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 output_length = | false | null | false | 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": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Lib.IntTypes.size_nat",
"Prims.unit"
] | [] | 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 } | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val output_length : _: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Spec.Hash.Definitions.output_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 19,
"end_line": 317,
"start_col": 20,
"start_line": 310
} |
|
Prims.Tot | val len_len (a: maxed_hash_alg) : Tot (n: size_t{v n = len_length a}) | [
{
"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
}
] | 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 | 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}) = | false | null | false | function
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 8ul
| SHA2_384 | SHA2_512 -> 16ul
| Blake2S -> 8ul
| Blake2B -> 16ul | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 *) | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | val len_len (a: maxed_hash_alg) : Tot (n: size_t{v n = len_length a}) | [] | Spec.Hash.Definitions.len_len | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | 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} | {
"end_col": 19,
"end_line": 162,
"start_col": 70,
"start_line": 158
} |
Prims.Tot | val len_v: a:maxed_hash_alg -> len_t a -> nat | [
{
"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
}
] | 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 | val len_v: a:maxed_hash_alg -> len_t a -> nat
let len_v = | false | null | false | 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 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | val len_v: a:maxed_hash_alg -> len_t a -> nat | [] | Spec.Hash.Definitions.len_v | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.maxed_hash_alg -> _: Spec.Hash.Definitions.len_t a -> Prims.nat | {
"end_col": 32,
"end_line": 145,
"start_col": 12,
"start_line": 140
} |
Prims.Tot | val hash_length' (a: _) (l: output_length a) : Lib.IntTypes.size_nat | [
{
"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
}
] | false | let hash_length' a (l: output_length a): Lib.IntTypes.size_nat =
if is_shake a then l else hash_length a | val hash_length' (a: _) (l: output_length a) : Lib.IntTypes.size_nat
let hash_length' a (l: output_length a) : Lib.IntTypes.size_nat = | false | null | false | if is_shake a then l else hash_length a | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | val hash_length' (a: _) (l: output_length a) : Lib.IntTypes.size_nat | [] | Spec.Hash.Definitions.hash_length' | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> l: Spec.Hash.Definitions.output_length a
-> Lib.IntTypes.size_nat | {
"end_col": 41,
"end_line": 320,
"start_col": 2,
"start_line": 320
} |
Prims.Tot | val pad_length (a: md_alg) (len: nat) : Tot (n: nat{(len + n) % block_length a = 0}) | [
{
"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
}
] | 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 | 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}) = | false | null | false | pad0_length a len + 1 + len_length a | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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. *) | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | val pad_length (a: md_alg) (len: nat) : Tot (n: nat{(len + n) % block_length a = 0}) | [] | Spec.Hash.Definitions.pad_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.md_alg -> len: Prims.nat
-> n: Prims.nat{(len + n) % Spec.Hash.Definitions.block_length a = 0} | {
"end_col": 38,
"end_line": 282,
"start_col": 2,
"start_line": 282
} |
Prims.Tot | val rate (a: keccak_alg) : (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) | [
{
"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
}
] | 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 | 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}) = | false | null | false | match a with
| SHA3_224 -> 1152
| SHA3_256 -> 1088
| SHA3_384 -> 832
| SHA3_512 -> 576
| Shake128 -> 1344
| Shake256 -> 1088 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"total"
] | [
"Spec.Hash.Definitions.keccak_alg",
"Lib.IntTypes.size_nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.op_LessThanOrEqual"
] | [] | 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 | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | val rate (a: keccak_alg) : (rate: size_nat{0 < rate / 8 /\ rate / 8 <= 200}) | [] | Spec.Hash.Definitions.rate | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.keccak_alg -> rate: Lib.IntTypes.size_nat{0 < rate / 8 /\ rate / 8 <= 200} | {
"end_col": 20,
"end_line": 203,
"start_col": 2,
"start_line": 197
} |
Prims.Tot | val max_input_length: hash_alg -> option pos | [
{
"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
}
] | 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 | val max_input_length: hash_alg -> option pos
let max_input_length: hash_alg -> option pos = | false | null | false | 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 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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. *) | false | true | Spec.Hash.Definitions.fst | {
"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"
} | null | val max_input_length: hash_alg -> option pos | [] | Spec.Hash.Definitions.max_input_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Spec.Hash.Definitions.hash_alg -> FStar.Pervasives.Native.option Prims.pos | {
"end_col": 75,
"end_line": 105,
"start_col": 47,
"start_line": 99
} |
Prims.Tot | val hash_length (a: hash_alg{not (is_shake a)}) : Lib.IntTypes.(n: size_nat{n > 0}) | [
{
"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
}
] | 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 | 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}) = | false | null | false | 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 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 *) | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | val hash_length (a: hash_alg{not (is_shake a)}) : Lib.IntTypes.(n: size_nat{n > 0}) | [] | Spec.Hash.Definitions.hash_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg{Prims.op_Negation (Spec.Hash.Definitions.is_shake a)}
-> n: Lib.IntTypes.size_nat{n > 0} | {
"end_col": 22,
"end_line": 272,
"start_col": 2,
"start_line": 262
} |
Prims.Tot | val pad0_length (a: md_alg) (len: nat)
: Tot (n: nat{(len + 1 + n + len_length a) % block_length a = 0}) | [
{
"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
}
] | 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 | 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}) = | false | null | false | (block_length a - (len + len_length a + 1)) % block_length a | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 *) | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | val pad0_length (a: md_alg) (len: nat)
: Tot (n: nat{(len + 1 + n + len_length a) % block_length a = 0}) | [] | Spec.Hash.Definitions.pad0_length | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | 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 } | {
"end_col": 62,
"end_line": 278,
"start_col": 2,
"start_line": 278
} |
Prims.Tot | 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))) | [
{
"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
}
] | 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 | 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))) = | false | null | false | 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": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 *) | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | 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))) | [] | Spec.Hash.Definitions.bytes_of_words | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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) | {
"end_col": 71,
"end_line": 290,
"start_col": 183,
"start_line": 287
} |
Prims.Tot | 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)) | [
{
"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
}
] | 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 | 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)) = | false | null | false | 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 | {
"checked_file": "Spec.Hash.Definitions.fst.checked",
"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"
} | [
"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"
] | [] | 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 | false | false | Spec.Hash.Definitions.fst | {
"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"
} | null | 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)) | [] | Spec.Hash.Definitions.words_of_bytes | {
"file_name": "specs/Spec.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
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 | {
"end_col": 73,
"end_line": 295,
"start_col": 183,
"start_line": 292
} |
Prims.Tot | val debug:ref bool | [
{
"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
}
] | false | let debug : ref bool = alloc false | val debug:ref bool
let debug:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val debug:ref bool | [] | Options.debug | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 34,
"end_line": 54,
"start_col": 23,
"start_line": 54
} |
Prims.Tot | val input_file:ref (list string) | [
{
"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
}
] | false | let input_file : ref (list string) = alloc [] | val input_file:ref (list string)
let input_file:ref (list string) = | false | null | false | alloc [] | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.list",
"Prims.string",
"FStar.Heap.trivial_preorder",
"Prims.Nil",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val input_file:ref (list string) | [] | Options.input_file | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (Prims.list Prims.string) | {
"end_col": 45,
"end_line": 56,
"start_col": 37,
"start_line": 56
} |
Prims.Tot | val arg0:ref (option vstring) | [
{
"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
}
] | false | let arg0 : ref (option vstring) = alloc None | val arg0:ref (option vstring)
let arg0:ref (option vstring) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | 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 *) | false | true | Options.fst | {
"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"
} | null | val arg0:ref (option vstring) | [] | Options.arg0 | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | {
"end_col": 44,
"end_line": 47,
"start_col": 34,
"start_line": 47
} |
Prims.Tot | val equate_types_list:ref (list (valid_string valid_equate_types)) | [
{
"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
}
] | false | let equate_types_list : ref (list (valid_string valid_equate_types)) = alloc [] | val equate_types_list:ref (list (valid_string valid_equate_types))
let equate_types_list:ref (list (valid_string valid_equate_types)) = | false | null | false | alloc [] | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.list",
"Options.valid_string",
"Options.valid_equate_types",
"FStar.Heap.trivial_preorder",
"Prims.Nil",
"FStar.ST.mref"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val equate_types_list:ref (list (valid_string valid_equate_types)) | [] | Options.equate_types_list | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (Prims.list (Options.valid_string Options.valid_equate_types)) | {
"end_col": 79,
"end_line": 93,
"start_col": 71,
"start_line": 93
} |
Prims.Tot | val z3_executable:ref (option vstring) | [
{
"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
}
] | false | let z3_executable : ref (option vstring) = alloc None | val z3_executable:ref (option vstring)
let z3_executable:ref (option vstring) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val z3_executable:ref (option vstring) | [] | Options.z3_executable | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | {
"end_col": 53,
"end_line": 134,
"start_col": 43,
"start_line": 134
} |
Prims.Tot | [
{
"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
}
] | false | 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 split_3d_file_name fn = | false | null | false | let fn = OS.basename fn in
if OS.extension fn = ".3d" then Some (OS.remove_extension fn) else None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.op_Equality",
"OS.extension",
"FStar.Pervasives.Native.Some",
"OS.remove_extension",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"OS.basename"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 | false | true | Options.fst | {
"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"
} | null | val split_3d_file_name : fn: Prims.string -> FStar.Pervasives.Native.option Prims.string | [] | Options.split_3d_file_name | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fn: Prims.string -> FStar.Pervasives.Native.option Prims.string | {
"end_col": 11,
"end_line": 401,
"start_col": 27,
"start_line": 397
} |
|
Prims.Tot | val batch:ref bool | [
{
"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
}
] | false | let batch : ref bool = alloc false | val batch:ref bool
let batch:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val batch:ref bool | [] | Options.batch | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 34,
"end_line": 49,
"start_col": 23,
"start_line": 49
} |
Prims.Tot | val valid_micro_step (str: string) : Tot bool | [
{
"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
}
] | false | let valid_micro_step (str: string) : Tot bool = match str with
| "verify"
| "extract"
| "copy_clang_format"
| "emit_config"
-> true
| _ -> false | val valid_micro_step (str: string) : Tot bool
let valid_micro_step (str: string) : Tot bool = | false | null | false | match str with
| "verify" | "extract" | "copy_clang_format" | "emit_config" -> true
| _ -> false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.bool"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val valid_micro_step (str: string) : Tot bool | [] | Options.valid_micro_step | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | str: Prims.string -> Prims.bool | {
"end_col": 14,
"end_line": 72,
"start_col": 48,
"start_line": 66
} |
Prims.Tot | val json:ref bool | [
{
"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
}
] | false | let json : ref bool = alloc false | val json:ref bool
let json:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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 [] | false | true | Options.fst | {
"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"
} | null | val json:ref bool | [] | Options.json | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 33,
"end_line": 57,
"start_col": 22,
"start_line": 57
} |
Prims.Tot | val z3_witnesses:ref (option vstring) | [
{
"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
}
] | false | let z3_witnesses : ref (option vstring) = alloc None | val z3_witnesses:ref (option vstring)
let z3_witnesses:ref (option vstring) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val z3_witnesses:ref (option vstring) | [] | Options.z3_witnesses | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | {
"end_col": 52,
"end_line": 132,
"start_col": 42,
"start_line": 132
} |
Prims.Tot | val z3_test:ref (option vstring) | [
{
"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
}
] | false | let z3_test : ref (option vstring) = alloc None | val z3_test:ref (option vstring)
let z3_test:ref (option vstring) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val z3_test:ref (option vstring) | [] | Options.z3_test | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | {
"end_col": 47,
"end_line": 121,
"start_col": 37,
"start_line": 121
} |
Prims.Tot | val skip_c_makefiles:ref bool | [
{
"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
}
] | false | let skip_c_makefiles : ref bool = alloc false | val skip_c_makefiles:ref bool
let skip_c_makefiles:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val skip_c_makefiles:ref bool | [] | Options.skip_c_makefiles | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 45,
"end_line": 62,
"start_col": 34,
"start_line": 62
} |
Prims.Tot | val valid_makefile (str: string) : Tot bool | [
{
"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
}
] | false | let valid_makefile (str: string) : Tot bool = match str with
| "gmake"
| "nmake"
-> true
| _ -> false | val valid_makefile (str: string) : Tot bool
let valid_makefile (str: string) : Tot bool = | false | null | false | match str with
| "gmake" | "nmake" -> true
| _ -> false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.bool"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val valid_makefile (str: string) : Tot bool | [] | Options.valid_makefile | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | str: Prims.string -> Prims.bool | {
"end_col": 14,
"end_line": 82,
"start_col": 46,
"start_line": 78
} |
Prims.Tot | val always_valid: string -> Tot bool | [
{
"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
}
] | false | let always_valid (_: string) : Tot bool = true | val always_valid: string -> Tot bool
let always_valid (_: string) : Tot bool = | false | null | false | true | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.bool"
] | [] | 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 }) | false | true | Options.fst | {
"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"
} | null | val always_valid: string -> Tot bool | [] | Options.always_valid | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.string -> Prims.bool | {
"end_col": 46,
"end_line": 16,
"start_col": 42,
"start_line": 16
} |
FStar.All.ML | val get_batch : unit -> ML bool | [
{
"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
}
] | false | let get_batch () =
!batch | val get_batch : unit -> ML bool
let get_batch () = | true | null | false | !batch | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.batch"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 () | false | false | Options.fst | {
"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"
} | null | val get_batch : unit -> ML bool | [] | Options.get_batch | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 8,
"end_line": 424,
"start_col": 2,
"start_line": 424
} |
Prims.Tot | val skip_deps:ref bool | [
{
"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
}
] | false | let skip_deps: ref bool = alloc false | val skip_deps:ref bool
let skip_deps:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val skip_deps:ref bool | [] | Options.skip_deps | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 37,
"end_line": 63,
"start_col": 26,
"start_line": 63
} |
FStar.All.ML | val debug_print_string (s:string) : ML unit | [
{
"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
}
] | false | let debug_print_string (s:string): ML unit =
if !debug
then FStar.IO.print_string s
else () | val debug_print_string (s:string) : ML unit
let debug_print_string (s: string) : ML unit = | true | null | false | if !debug then FStar.IO.print_string s | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.string",
"FStar.IO.print_string",
"Prims.unit",
"Prims.bool",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.debug"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 | false | false | Options.fst | {
"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"
} | null | val debug_print_string (s:string) : ML unit | [] | Options.debug_print_string | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: Prims.string -> FStar.All.ML Prims.unit | {
"end_col": 9,
"end_line": 421,
"start_col": 2,
"start_line": 419
} |
Prims.Tot | val valid_equate_types (str: string) : Tot bool | [
{
"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
}
] | false | let valid_equate_types (str: string) : Tot bool =
let l = String.split [','] str in
match l with
| [m1;m2] -> true
| _ -> false | val valid_equate_types (str: string) : Tot bool
let valid_equate_types (str: string) : Tot bool = | false | null | false | let l = String.split [','] str in
match l with
| [m1 ; m2] -> true
| _ -> false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.list",
"Prims.bool",
"FStar.String.split",
"Prims.Cons",
"FStar.String.char",
"Prims.Nil"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val valid_equate_types (str: string) : Tot bool | [] | Options.valid_equate_types | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | str: Prims.string -> Prims.bool | {
"end_col": 17,
"end_line": 91,
"start_col": 49,
"start_line": 87
} |
Prims.Tot | val valid_string (valid: (string -> Tot bool)) : Tot Type0 | [
{
"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
}
] | false | let valid_string
(valid: (string -> Tot bool))
: Tot Type0
= (s: string { valid s == true }) | val valid_string (valid: (string -> Tot bool)) : Tot Type0
let valid_string (valid: (string -> Tot bool)) : Tot Type0 = | false | null | false | (s: string{valid s == true}) | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.bool",
"Prims.eq2"
] | [] | 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)) | false | true | Options.fst | {
"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"
} | null | val valid_string (valid: (string -> Tot bool)) : Tot Type0 | [] | Options.valid_string | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | valid: (_: Prims.string -> Prims.bool) -> Type0 | {
"end_col": 33,
"end_line": 14,
"start_col": 2,
"start_line": 14
} |
Prims.Tot | val add_include:ref (list vstring) | [
{
"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
}
] | false | let add_include : ref (list vstring) = alloc [] | val add_include:ref (list vstring)
let add_include:ref (list vstring) = | false | null | false | alloc [] | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.list",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"Prims.Nil",
"FStar.ST.mref"
] | [] | 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 *) | false | true | Options.fst | {
"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"
} | null | val add_include:ref (list vstring) | [] | Options.add_include | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (Prims.list Options.vstring) | {
"end_col": 47,
"end_line": 48,
"start_col": 39,
"start_line": 48
} |
Prims.Tot | val produce_c_from_existing_krml:ref bool | [
{
"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
}
] | false | let produce_c_from_existing_krml : ref bool = alloc false | val produce_c_from_existing_krml:ref bool
let produce_c_from_existing_krml:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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"
| "emit_config"
-> true
| _ -> false
let micro_step : ref (option (valid_string valid_micro_step)) = alloc None | false | true | Options.fst | {
"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"
} | null | val produce_c_from_existing_krml:ref bool | [] | Options.produce_c_from_existing_krml | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 57,
"end_line": 76,
"start_col": 46,
"start_line": 76
} |
Prims.Tot | val negate_name (s: string) : Tot string | [
{
"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
}
] | false | let negate_name (s: string) : Tot string = negate_string_gen s "no_" | val negate_name (s: string) : Tot string
let negate_name (s: string) : Tot string = | false | null | false | negate_string_gen s "no_" | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Options.negate_string_gen"
] | [] | 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"
| "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
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
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.Getopt.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 | false | true | Options.fst | {
"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"
} | null | val negate_name (s: string) : Tot string | [] | Options.negate_name | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: Prims.string -> Prims.string | {
"end_col": 68,
"end_line": 215,
"start_col": 43,
"start_line": 215
} |
Prims.Tot | val emit_smt_encoding:ref bool | [
{
"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
}
] | false | let emit_smt_encoding : ref bool = alloc false | val emit_smt_encoding:ref bool
let emit_smt_encoding:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val emit_smt_encoding:ref bool | [] | Options.emit_smt_encoding | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 46,
"end_line": 117,
"start_col": 35,
"start_line": 117
} |
Prims.Tot | val input_stream_binding:ref (option (valid_string valid_input_stream_binding)) | [
{
"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
}
] | false | let input_stream_binding : ref (option (valid_string valid_input_stream_binding)) = alloc None | val input_stream_binding:ref (option (valid_string valid_input_stream_binding))
let input_stream_binding:ref (option (valid_string valid_input_stream_binding)) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"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"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val input_stream_binding:ref (option (valid_string valid_input_stream_binding)) | [] | Options.input_stream_binding | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_input_stream_binding
)) | {
"end_col": 94,
"end_line": 111,
"start_col": 84,
"start_line": 111
} |
FStar.All.ML | val get_cleanup : unit -> ML bool | [
{
"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
}
] | false | let get_cleanup () =
!cleanup | val get_cleanup : unit -> ML bool
let get_cleanup () = | true | null | false | !cleanup | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.cleanup"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 | false | false | Options.fst | {
"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"
} | null | val get_cleanup : unit -> ML bool | [] | Options.get_cleanup | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 10,
"end_line": 435,
"start_col": 2,
"start_line": 435
} |
Prims.Tot | val check_hashes:ref (option (valid_string valid_check_hashes)) | [
{
"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
}
] | false | let check_hashes : ref (option (valid_string valid_check_hashes)) = alloc None | val check_hashes:ref (option (valid_string valid_check_hashes))
let check_hashes:ref (option (valid_string valid_check_hashes)) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"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"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val check_hashes:ref (option (valid_string valid_check_hashes)) | [] | Options.check_hashes | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_check_hashes)) | {
"end_col": 78,
"end_line": 102,
"start_col": 68,
"start_line": 102
} |
FStar.All.ML | val get_clang_format : unit -> ML bool | [
{
"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
}
] | false | let get_clang_format () =
!clang_format | val get_clang_format : unit -> ML bool
let get_clang_format () = | true | null | false | !clang_format | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.clang_format"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 | false | false | Options.fst | {
"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"
} | null | val get_clang_format : unit -> ML bool | [] | Options.get_clang_format | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 15,
"end_line": 427,
"start_col": 2,
"start_line": 427
} |
Prims.Tot | val negate_description (s: string) : Tot string | [
{
"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
}
] | false | let negate_description (s: string) : Tot string = negate_string_gen s "Do not" | val negate_description (s: string) : Tot string
let negate_description (s: string) : Tot string = | false | null | false | negate_string_gen s "Do not" | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Options.negate_string_gen"
] | [] | 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"
| "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
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
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.Getopt.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_" | false | true | Options.fst | {
"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"
} | null | val negate_description (s: string) : Tot string | [] | Options.negate_description | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: Prims.string -> Prims.string | {
"end_col": 78,
"end_line": 216,
"start_col": 50,
"start_line": 216
} |
FStar.All.ML | val get_file_name (mname:string) : ML string | [
{
"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
}
] | false | let get_file_name mname = mname ^ ".3d" | val get_file_name (mname:string) : ML string
let get_file_name mname = | true | null | false | mname ^ ".3d" | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.string",
"Prims.op_Hat"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 | false | false | Options.fst | {
"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"
} | null | val get_file_name (mname:string) : ML string | [] | Options.get_file_name | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | mname: Prims.string -> FStar.All.ML Prims.string | {
"end_col": 39,
"end_line": 403,
"start_col": 26,
"start_line": 403
} |
FStar.All.ML | val display_usage : unit -> ML unit | [
{
"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
}
] | false | let display_usage = display_usage_2 | val display_usage : unit -> ML unit
let display_usage = | true | null | false | display_usage_2 | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Options.display_usage_2"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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) | false | false | Options.fst | {
"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"
} | null | val display_usage : unit -> ML unit | [] | Options.display_usage | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.unit | {
"end_col": 35,
"end_line": 384,
"start_col": 20,
"start_line": 384
} |
FStar.All.ML | val get_debug: unit -> ML bool | [
{
"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
}
] | false | let get_debug _ = !debug | val get_debug: unit -> ML bool
let get_debug _ = | true | null | false | !debug | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.debug"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs
let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config")
let get_emit_smt_encoding () =
!emit_smt_encoding
let get_z3_test () = !z3_test
let get_z3_pos_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "neg" -> false
| _ -> true
let get_z3_neg_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "pos" -> false
| _ -> true
let get_z3_witnesses () =
match !z3_witnesses with
| None -> 1
| Some s ->
try
let n = OS.int_of_string s in
if n < 1 then 1 else n
with _ -> 1 | false | false | Options.fst | {
"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"
} | null | val get_debug: unit -> ML bool | [] | Options.get_debug | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 24,
"end_line": 564,
"start_col": 18,
"start_line": 564
} |
FStar.All.ML | val get_skip_o_rules : unit -> ML bool | [
{
"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
}
] | false | let get_skip_o_rules _ =
!skip_o_rules | val get_skip_o_rules : unit -> ML bool
let get_skip_o_rules _ = | true | null | false | !skip_o_rules | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.skip_o_rules"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf | false | false | Options.fst | {
"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"
} | null | val get_skip_o_rules : unit -> ML bool | [] | Options.get_skip_o_rules | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 15,
"end_line": 490,
"start_col": 2,
"start_line": 490
} |
FStar.All.ML | val get_z3_neg_test: unit -> ML bool | [
{
"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
}
] | false | let get_z3_neg_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "pos" -> false
| _ -> true | val get_z3_neg_test: unit -> ML bool
let get_z3_neg_test () = | true | null | false | match !z3_test with
| None -> false
| _ ->
match !z3_test_mode with
| Some "pos" -> false
| _ -> true | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.unit",
"Prims.bool",
"FStar.Pervasives.Native.option",
"Options.vstring",
"Options.valid_string",
"Options.valid_z3_test_mode",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.z3_test_mode",
"Options.z3_test"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs
let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config")
let get_emit_smt_encoding () =
!emit_smt_encoding
let get_z3_test () = !z3_test
let get_z3_pos_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "neg" -> false
| _ -> true | false | false | Options.fst | {
"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"
} | null | val get_z3_neg_test: unit -> ML bool | [] | Options.get_z3_neg_test | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 13,
"end_line": 553,
"start_col": 2,
"start_line": 549
} |
FStar.All.ML | val get_no_everparse_h : unit -> ML bool | [
{
"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
}
] | false | let get_no_everparse_h () =
!no_copy_everparse_h | val get_no_everparse_h : unit -> ML bool
let get_no_everparse_h () = | true | null | false | !no_copy_everparse_h | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.unit",
"FStar.ST.op_Bang",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"Options.no_copy_everparse_h"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 | false | false | Options.fst | {
"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"
} | null | val get_no_everparse_h : unit -> ML bool | [] | Options.get_no_everparse_h | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 22,
"end_line": 441,
"start_col": 2,
"start_line": 441
} |
FStar.All.ML | val get_z3_pos_test: unit -> ML bool | [
{
"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
}
] | false | let get_z3_pos_test () =
match !z3_test with
| None -> false
| _ -> match !z3_test_mode with
| Some "neg" -> false
| _ -> true | val get_z3_pos_test: unit -> ML bool
let get_z3_pos_test () = | true | null | false | match !z3_test with
| None -> false
| _ ->
match !z3_test_mode with
| Some "neg" -> false
| _ -> true | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"Prims.unit",
"Prims.bool",
"FStar.Pervasives.Native.option",
"Options.vstring",
"Options.valid_string",
"Options.valid_z3_test_mode",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.z3_test_mode",
"Options.z3_test"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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" [];
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_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_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" [];
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|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 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 "emit_config" -> Some MicroStepEmitConfig
let get_produce_c_from_existing_krml _ =
!produce_c_from_existing_krml
let get_skip_deps _ =
!skip_deps
let get_makefile _ =
match !makefile with
| None -> None
| Some "gmake" -> Some MakefileGMake
| Some "nmake" -> Some MakefileNMake
let get_makefile_name _ =
match !makefile_name with
| None -> OS.concat (get_output_dir ()) "EverParse.Makefile"
| Some mf -> mf
let get_skip_o_rules _ =
!skip_o_rules
let get_json () =
!json
let get_input_stream_binding _ =
let get_include () =
match !input_stream_include with
| None -> ""
| Some s -> s
in
match !input_stream_binding with
| None
| Some "buffer" -> InputStreamBuffer
| Some "extern" ->
InputStreamExtern (get_include ())
| Some "static" ->
InputStreamStatic (get_include ())
let get_emit_output_types_defs () = !emit_output_types_defs
let get_config_file () =
match !config_file with
| None -> None
| Some s -> Some s
let get_add_include () =
!add_include
let make_includes () =
let incs = get_add_include () in
List.Tot.fold_left
(fun accu inc ->
Printf.sprintf
"%s#include %s\n"
accu
inc
)
""
incs
let config_module_name () =
match !config_file with
| None -> None
| Some s -> Some (strip_suffix (OS.basename s) ".3d.config")
let get_emit_smt_encoding () =
!emit_smt_encoding
let get_z3_test () = !z3_test | false | false | Options.fst | {
"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"
} | null | val get_z3_pos_test: unit -> ML bool | [] | Options.get_z3_pos_test | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> FStar.All.ML Prims.bool | {
"end_col": 13,
"end_line": 546,
"start_col": 2,
"start_line": 542
} |
FStar.All.ML | val display_usage_1 (options: ref (list cmd_option)) : ML unit | [
{
"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
}
] | false | 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 [])) | val display_usage_1 (options: ref (list cmd_option)) : ML unit
let display_usage_1 (options: ref (list cmd_option)) : ML unit = | true | null | false | 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 [])) | {
"checked_file": "Options.fst.checked",
"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"
} | [
"ml"
] | [
"FStar.ST.ref",
"Prims.list",
"Options.cmd_option",
"FStar.IO.print_string",
"Prims.unit",
"Prims.string",
"FStar.Printf.sprintf",
"Options.compute_current_options",
"Prims.Nil",
"FStar.List.iter",
"Prims.bool",
"Prims.op_Negation",
"Options.string_starts_with",
"Options.uu___is_CmdOption",
"Options.negate_name",
"Prims.op_Equality",
"Options.cmd_option_arg_desc",
"Options.cmd_option_description",
"Options.cmd_option_name",
"FStar.ST.op_Bang",
"FStar.Heap.trivial_preorder",
"Options.get_arg0"
] | [] | 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"
| "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
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
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.Getopt.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.Getopt.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 | false | false | Options.fst | {
"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"
} | null | val display_usage_1 (options: ref (list cmd_option)) : ML unit | [] | Options.display_usage_1 | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | options: FStar.ST.ref (Prims.list Options.cmd_option) -> FStar.All.ML Prims.unit | {
"end_col": 106,
"end_line": 337,
"start_col": 2,
"start_line": 320
} |
Prims.Tot | val check_config_file_name (fn: string) : bool | [
{
"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
}
] | false | let check_config_file_name (fn:string)
: bool
= let fn = OS.basename fn in
starts_with_capital fn &&
ends_with fn ".3d.config" | val check_config_file_name (fn: string) : bool
let check_config_file_name (fn: string) : bool = | false | null | false | let fn = OS.basename fn in
starts_with_capital fn && ends_with fn ".3d.config" | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.op_AmpAmp",
"Options.starts_with_capital",
"Options.ends_with",
"OS.basename",
"Prims.bool"
] | [] | 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) | false | true | Options.fst | {
"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"
} | null | val check_config_file_name (fn: string) : bool | [] | Options.check_config_file_name | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fn: Prims.string -> Prims.bool | {
"end_col": 29,
"end_line": 36,
"start_col": 3,
"start_line": 34
} |
Prims.Tot | val clang_format_executable:ref (option vstring) | [
{
"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
}
] | false | let clang_format_executable : ref (option vstring) = alloc None | val clang_format_executable:ref (option vstring)
let clang_format_executable:ref (option vstring) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val clang_format_executable:ref (option vstring) | [] | Options.clang_format_executable | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | {
"end_col": 63,
"end_line": 51,
"start_col": 53,
"start_line": 51
} |
Prims.Tot | val config_file:ref (option (valid_string check_config_file_name)) | [
{
"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
}
] | false | let config_file : ref (option (valid_string check_config_file_name)) = alloc None | val config_file:ref (option (valid_string check_config_file_name))
let config_file:ref (option (valid_string check_config_file_name)) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"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"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val config_file:ref (option (valid_string check_config_file_name)) | [] | Options.config_file | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.check_config_file_name)) | {
"end_col": 81,
"end_line": 53,
"start_col": 71,
"start_line": 53
} |
Prims.Tot | val save_hashes:ref bool | [
{
"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
}
] | false | let save_hashes : ref bool = alloc false | val save_hashes:ref bool
let save_hashes:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val save_hashes:ref bool | [] | Options.save_hashes | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 40,
"end_line": 60,
"start_col": 29,
"start_line": 60
} |
Prims.Tot | val cleanup:ref bool | [
{
"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
}
] | false | let cleanup : ref bool = alloc false | val cleanup:ref bool
let cleanup:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val cleanup:ref bool | [] | Options.cleanup | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 36,
"end_line": 52,
"start_col": 25,
"start_line": 52
} |
Prims.Tot | val save_z3_transcript:ref (option vstring) | [
{
"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
}
] | false | let save_z3_transcript: ref (option vstring) = alloc None | val save_z3_transcript:ref (option vstring)
let save_z3_transcript:ref (option vstring) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val save_z3_transcript:ref (option vstring) | [] | Options.save_z3_transcript | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | {
"end_col": 57,
"end_line": 61,
"start_col": 47,
"start_line": 61
} |
Prims.Tot | val no_copy_everparse_h:ref bool | [
{
"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
}
] | false | let no_copy_everparse_h : ref bool = alloc false | val no_copy_everparse_h:ref bool
let no_copy_everparse_h:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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 [] | false | true | Options.fst | {
"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"
} | null | val no_copy_everparse_h:ref bool | [] | Options.no_copy_everparse_h | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 48,
"end_line": 58,
"start_col": 37,
"start_line": 58
} |
Prims.Tot | val inplace_hashes:ref (list vstring) | [
{
"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
}
] | false | let inplace_hashes : ref (list vstring) = alloc [] | val inplace_hashes:ref (list vstring)
let inplace_hashes:ref (list vstring) = | false | null | false | alloc [] | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.list",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"Prims.Nil",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val inplace_hashes:ref (list vstring) | [] | Options.inplace_hashes | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (Prims.list Options.vstring) | {
"end_col": 50,
"end_line": 55,
"start_col": 42,
"start_line": 55
} |
Prims.Tot | val valid_check_hashes: string -> Tot bool | [
{
"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
}
] | false | let valid_check_hashes : string -> Tot bool = function
| "weak"
| "strong"
| "inplace"
-> true
| _ -> false | val valid_check_hashes: string -> Tot bool
let valid_check_hashes: string -> Tot bool = | false | null | false | function
| "weak" | "strong" | "inplace" -> true
| _ -> false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.bool"
] | [] | 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"
| "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 [] | false | true | Options.fst | {
"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"
} | null | val valid_check_hashes: string -> Tot bool | [] | Options.valid_check_hashes | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.string -> Prims.bool | {
"end_col": 12,
"end_line": 100,
"start_col": 46,
"start_line": 95
} |
Prims.Tot | val makefile:ref (option (valid_string valid_makefile)) | [
{
"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
}
] | false | let makefile : ref (option (valid_string valid_makefile)) = alloc None | val makefile:ref (option (valid_string valid_makefile))
let makefile:ref (option (valid_string valid_makefile)) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"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"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val makefile:ref (option (valid_string valid_makefile)) | [] | Options.makefile | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_makefile)) | {
"end_col": 70,
"end_line": 84,
"start_col": 60,
"start_line": 84
} |
Prims.Tot | val input_stream_include:ref (option vstring) | [
{
"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
}
] | false | let input_stream_include : ref (option vstring) = alloc None | val input_stream_include:ref (option vstring)
let input_stream_include:ref (option vstring) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val input_stream_include:ref (option vstring) | [] | Options.input_stream_include | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | {
"end_col": 60,
"end_line": 113,
"start_col": 50,
"start_line": 113
} |
Prims.Tot | val z3_test_mode:ref (option (valid_string valid_z3_test_mode)) | [
{
"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
}
] | false | let z3_test_mode : ref (option (valid_string valid_z3_test_mode)) = alloc None | val z3_test_mode:ref (option (valid_string valid_z3_test_mode))
let z3_test_mode:ref (option (valid_string valid_z3_test_mode)) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"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"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val z3_test_mode:ref (option (valid_string valid_z3_test_mode)) | [] | Options.z3_test_mode | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option (Options.valid_string Options.valid_z3_test_mode)) | {
"end_col": 78,
"end_line": 130,
"start_col": 68,
"start_line": 130
} |
Prims.Tot | val valid_input_stream_binding: string -> Tot bool | [
{
"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
}
] | false | let valid_input_stream_binding : string -> Tot bool = function
| "buffer"
| "extern"
| "static"
-> true
| _ -> false | val valid_input_stream_binding: string -> Tot bool
let valid_input_stream_binding: string -> Tot bool = | false | null | false | function
| "buffer" | "extern" | "static" -> true
| _ -> false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.bool"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val valid_input_stream_binding: string -> Tot bool | [] | Options.valid_input_stream_binding | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.string -> Prims.bool | {
"end_col": 12,
"end_line": 109,
"start_col": 54,
"start_line": 104
} |
Prims.Tot | val clang_format:ref bool | [
{
"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
}
] | false | let clang_format : ref bool = alloc false | val clang_format:ref bool
let clang_format:ref bool = | false | null | false | alloc false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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 [] | false | true | Options.fst | {
"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"
} | null | val clang_format:ref bool | [] | Options.clang_format | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 41,
"end_line": 50,
"start_col": 30,
"start_line": 50
} |
Prims.Tot | val emit_output_types_defs:ref bool | [
{
"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
}
] | false | let emit_output_types_defs : ref bool = alloc true | val emit_output_types_defs:ref bool
let emit_output_types_defs:ref bool = | false | null | false | alloc true | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"Prims.bool",
"FStar.Heap.trivial_preorder",
"FStar.ST.mref"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val emit_output_types_defs:ref bool | [] | Options.emit_output_types_defs | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref Prims.bool | {
"end_col": 50,
"end_line": 115,
"start_col": 40,
"start_line": 115
} |
Prims.Tot | val valid_z3_test_mode: string -> Tot bool | [
{
"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
}
] | false | let valid_z3_test_mode : string -> Tot bool = function
| "pos"
| "neg"
| "all"
-> true
| _ -> false | val valid_z3_test_mode: string -> Tot bool
let valid_z3_test_mode: string -> Tot bool = | false | null | false | function
| "pos" | "neg" | "all" -> true
| _ -> false | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Prims.bool"
] | [] | 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"
| "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 | false | true | Options.fst | {
"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"
} | null | val valid_z3_test_mode: string -> Tot bool | [] | Options.valid_z3_test_mode | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.string -> Prims.bool | {
"end_col": 12,
"end_line": 128,
"start_col": 46,
"start_line": 123
} |
Prims.Tot | [
{
"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
}
] | false | let vstring = valid_string always_valid | let vstring = | false | null | false | valid_string always_valid | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Options.valid_string",
"Options.always_valid"
] | [] | 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) | false | true | Options.fst | {
"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"
} | null | val vstring : Type0 | [] | Options.vstring | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Type0 | {
"end_col": 39,
"end_line": 43,
"start_col": 14,
"start_line": 43
} |
|
Prims.Tot | val name_is_negated (s: string) : Tot bool | [
{
"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
}
] | false | let name_is_negated (s: string) : Tot bool = s `string_starts_with` "no_" | val name_is_negated (s: string) : Tot bool
let name_is_negated (s: string) : Tot bool = | false | null | false | s `string_starts_with` "no_" | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"Prims.string",
"Options.string_starts_with",
"Prims.bool"
] | [] | 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"
| "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
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
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.Getopt.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 | false | true | Options.fst | {
"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"
} | null | val name_is_negated (s: string) : Tot bool | [] | Options.name_is_negated | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | s: Prims.string -> Prims.bool | {
"end_col": 73,
"end_line": 214,
"start_col": 45,
"start_line": 214
} |
Prims.Tot | val output_dir:ref (option vstring) | [
{
"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
}
] | false | let output_dir : ref (option vstring) = alloc None | val output_dir:ref (option vstring)
let output_dir:ref (option vstring) = | false | null | false | alloc None | {
"checked_file": "Options.fst.checked",
"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"
} | [
"total"
] | [
"FStar.ST.alloc",
"FStar.Pervasives.Native.option",
"Options.vstring",
"FStar.Heap.trivial_preorder",
"FStar.Pervasives.Native.None",
"FStar.ST.mref"
] | [] | 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 | false | true | Options.fst | {
"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"
} | null | val output_dir:ref (option vstring) | [] | Options.output_dir | {
"file_name": "src/3d/Options.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | FStar.ST.ref (FStar.Pervasives.Native.option Options.vstring) | {
"end_col": 50,
"end_line": 59,
"start_col": 40,
"start_line": 59
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.