file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Spec.AES.Test.fst | Spec.AES.Test.test_plaintext1 | val test_plaintext1:lbytes 16 | val test_plaintext1:lbytes 16 | let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 69,
"start_col": 0,
"start_line": 64
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1 | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test_plaintext1:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy; 0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy;
0x20uy; 0x6Duy; 0x73uy; 0x67uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test1_key_block | val test1_key_block:lbytes 16 | val test1_key_block:lbytes 16 | let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 122,
"start_col": 0,
"start_line": 117
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test1_key_block:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test_plaintext2 | val test_plaintext2:lbytes 32 | val test_plaintext2:lbytes 32 | let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 104,
"start_col": 0,
"start_line": 97
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1 | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test_plaintext2:lbytes 32 =
| let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0Auy; 0x0Buy;
0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test_ciphertext2 | val test_ciphertext2:lbytes 32 | val test_ciphertext2:lbytes 32 | let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 114,
"start_col": 0,
"start_line": 107
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test_ciphertext2:lbytes 32 =
| let l =
List.Tot.map u8_from_UInt8
[
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy; 0x79uy; 0x0Duy; 0x41uy; 0xEEuy;
0x8Euy; 0xDAuy; 0xD3uy; 0x88uy; 0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test3_key_block | val test3_key_block:lbytes 16 | val test3_key_block:lbytes 16 | let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 170,
"start_col": 0,
"start_line": 165
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test3_key_block:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy; 0x6duy; 0x6auy; 0x8fuy; 0x94uy;
0x67uy; 0x30uy; 0x83uy; 0x08uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test1_plaintext_block | val test1_plaintext_block:lbytes 16 | val test1_plaintext_block:lbytes 16 | let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 130,
"start_col": 0,
"start_line": 125
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test1_plaintext_block:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test2_output_ciphertext | val test2_output_ciphertext:lbytes 16 | val test2_output_ciphertext:lbytes 16 | let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 251,
"start_col": 0,
"start_line": 246
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test2_output_ciphertext:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy; 0xeauy; 0xfcuy; 0x49uy; 0x90uy;
0x4buy; 0x49uy; 0x60uy; 0x89uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test2_plaintext_block | val test2_plaintext_block:lbytes 16 | val test2_plaintext_block:lbytes 16 | let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 154,
"start_col": 0,
"start_line": 149
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test2_plaintext_block:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test1_ciphertext_block | val test1_ciphertext_block:lbytes 16 | val test1_ciphertext_block:lbytes 16 | let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 138,
"start_col": 0,
"start_line": 133
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test1_ciphertext_block:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy; 0x45uy; 0x5buy; 0xd8uy; 0xbauy;
0x14uy; 0x18uy; 0xbeuy; 0xc8uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test3_input_key | val test3_input_key:lbytes 32 | val test3_input_key:lbytes 32 | let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 261,
"start_col": 0,
"start_line": 254
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test3_input_key:lbytes 32 =
| let l =
List.Tot.map u8_from_UInt8
[
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy; 0xecuy; 0x47uy; 0x57uy; 0xf2uy;
0x2fuy; 0xfeuy; 0xeeuy; 0x35uy; 0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test2_input_plaintext | val test2_input_plaintext:lbytes 16 | val test2_input_plaintext:lbytes 16 | let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 243,
"start_col": 0,
"start_line": 238
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test2_input_plaintext:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy; 0x88uy; 0x99uy; 0xaauy; 0xbbuy;
0xccuy; 0xdduy; 0xeeuy; 0xffuy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test3_ciphertext_block | val test3_ciphertext_block:lbytes 16 | val test3_ciphertext_block:lbytes 16 | let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 178,
"start_col": 0,
"start_line": 173
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test3_ciphertext_block:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy; 0x0auy; 0xa6uy; 0xe5uy; 0x29uy;
0x80uy; 0xd5uy; 0x3buy; 0x78uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test4_input_key | val test4_input_key:lbytes 32 | val test4_input_key:lbytes 32 | let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 287,
"start_col": 0,
"start_line": 280
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test4_input_key:lbytes 32 =
| let l =
List.Tot.map u8_from_UInt8
[
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy; 0x9buy; 0xc4uy; 0x37uy; 0x48uy;
0x4euy; 0x3cuy; 0x5cuy; 0x72uy; 0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test1_input_key1 | val test1_input_key1:lbytes 32 | val test1_input_key1:lbytes 32 | let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 188,
"start_col": 0,
"start_line": 181
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test1_input_key1:lbytes 32 =
| let l =
List.Tot.map u8_from_UInt8
[
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy; 0x2buy; 0x73uy; 0xaeuy; 0xf0uy;
0x85uy; 0x7duy; 0x77uy; 0x81uy; 0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test2_input_key | val test2_input_key:lbytes 32 | val test2_input_key:lbytes 32 | let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 235,
"start_col": 0,
"start_line": 228
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test2_input_key:lbytes 32 =
| let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy;
0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy
]
in
assert_norm (List.Tot.length l == 32);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test3_output_ciphertext | val test3_output_ciphertext:lbytes 16 | val test3_output_ciphertext:lbytes 16 | let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 277,
"start_col": 0,
"start_line": 272
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test3_output_ciphertext:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy; 0x77uy; 0x47uy; 0x6fuy; 0xc5uy;
0x01uy; 0x24uy; 0x2cuy; 0x5fuy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test_vectors | val test_vectors:list vec | val test_vectors:list vec | let test_vectors : list vec = [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
] | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 1,
"end_line": 353,
"start_col": 0,
"start_line": 342
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n"
(*
let seqsbox_16 = map (fun s -> sbox_bp_16 s) seqi in
IO.print_string "sbox bp_i i:\n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox_16);
IO.print_string "\n";
*)
noeq type vec =
| Vec :
v:variant
-> key:aes_key v
-> nonce:bytes{length nonce <= 16}
-> c:size_nat
-> msg:bytes{length msg / 16 + c <= max_size_t}
-> expected:bytes{length msg = length expected /\ length msg <= max_size_t} -> vec
| Vec_block :
v:variant
-> key:aes_key v
-> plain:block
-> expected:block -> vec | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.list Spec.AES.Test.vec | Prims.Tot | [
"total"
] | [] | [
"Prims.Cons",
"Spec.AES.Test.vec",
"Spec.AES.Test.Vec",
"Spec.AES.AES128",
"Spec.AES.Test.test_key",
"Spec.AES.Test.test_nonce",
"Spec.AES.Test.test_counter",
"Spec.AES.Test.test_plaintext",
"Spec.AES.Test.test_ciphertext",
"Spec.AES.Test.test_key1",
"Spec.AES.Test.test_nonce1",
"Spec.AES.Test.test_counter1",
"Spec.AES.Test.test_plaintext1",
"Spec.AES.Test.test_ciphertext1",
"Spec.AES.Test.test_key2",
"Spec.AES.Test.test_nonce2",
"Spec.AES.Test.test_counter2",
"Spec.AES.Test.test_plaintext2",
"Spec.AES.Test.test_ciphertext2",
"Spec.AES.Test.Vec_block",
"Spec.AES.Test.test1_key_block",
"Spec.AES.Test.test1_plaintext_block",
"Spec.AES.Test.test1_ciphertext_block",
"Spec.AES.Test.test2_key_block",
"Spec.AES.Test.test2_plaintext_block",
"Spec.AES.Test.test2_ciphertext_block",
"Spec.AES.Test.test3_key_block",
"Spec.AES.Test.test3_ciphertext_block",
"Spec.AES.AES256",
"Spec.AES.Test.test2_input_key",
"Spec.AES.Test.test2_input_plaintext",
"Spec.AES.Test.test2_output_ciphertext",
"Spec.AES.Test.test3_input_key",
"Spec.AES.Test.test3_input_plaintext",
"Spec.AES.Test.test3_output_ciphertext",
"Spec.AES.Test.test4_input_key",
"Spec.AES.Test.test4_input_plaintext",
"Spec.AES.Test.test4_output_ciphertext",
"Prims.Nil"
] | [] | false | false | false | true | false | let test_vectors:list vec =
| [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
] | false |
Spec.AES.Test.fst | Spec.AES.Test.test2_ciphertext_block | val test2_ciphertext_block:lbytes 16 | val test2_ciphertext_block:lbytes 16 | let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 162,
"start_col": 0,
"start_line": 157
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test2_ciphertext_block:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy; 0x91uy; 0xc5uy; 0x7duy; 0x9fuy;
0xb6uy; 0x85uy; 0x48uy; 0xd1uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Lib.IntTypes.fsti | Lib.IntTypes.unsigned | val unsigned : _: Lib.IntTypes.inttype -> Prims.bool | let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 26,
"start_col": 0,
"start_line": 24
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Lib.IntTypes.inttype -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.bool"
] | [] | false | false | false | true | false | let unsigned =
| function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false | false |
|
Spec.AES.Test.fst | Spec.AES.Test.test3_input_plaintext | val test3_input_plaintext:lbytes 16 | val test3_input_plaintext:lbytes 16 | let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 269,
"start_col": 0,
"start_line": 264
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test3_input_plaintext:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test4_input_plaintext | val test4_input_plaintext:lbytes 16 | val test4_input_plaintext:lbytes 16 | let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 295,
"start_col": 0,
"start_line": 290
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test4_input_plaintext:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Lib.IntTypes.fsti | Lib.IntTypes.signed | val signed : _: Lib.IntTypes.inttype -> Prims.bool | let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 33,
"start_col": 0,
"start_line": 31
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Lib.IntTypes.inttype -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.bool"
] | [] | false | false | false | true | false | let signed =
| function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false | false |
|
Spec.AES.Test.fst | Spec.AES.Test.print_sbox | val print_sbox: Prims.unit -> FStar.All.ML unit | val print_sbox: Prims.unit -> FStar.All.ML unit | let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n" | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 318,
"start_col": 0,
"start_line": 306
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.All.ML Prims.unit | FStar.All.ML | [
"ml"
] | [] | [
"Prims.unit",
"FStar.IO.print_string",
"FStar.List.iter",
"Lib.IntTypes.uint8",
"FStar.UInt8.to_string",
"Lib.RawIntTypes.u8_to_UInt8",
"Lib.Sequence.to_list",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.Sequence.index",
"Spec.AES.sub_byte",
"Spec.AES.elem",
"Lib.Sequence.map",
"Lib.LoopCombinators.repeati",
"Lib.Sequence.op_String_Assignment",
"Lib.IntTypes.u8",
"Prims.l_and",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Lib.Sequence.create"
] | [] | false | true | false | false | false | let print_sbox () : FStar.All.ML unit =
| let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[ i ] <- u8 i) seq in
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a ->
IO.print_string (UInt8.to_string (u8_to_UInt8 a));
IO.print_string " ; ")
(to_list #uint8 seqsbox);
IO.print_string "\n" | false |
Lib.IntTypes.fsti | Lib.IntTypes.range | val range (n: int) (t: inttype) : Type0 | val range (n: int) (t: inttype) : Type0 | let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 88,
"start_col": 0,
"start_line": 87
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.int -> t: Lib.IntTypes.inttype -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Lib.IntTypes.inttype",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.minint",
"Lib.IntTypes.maxint"
] | [] | false | false | false | true | true | let range (n: int) (t: inttype) : Type0 =
| minint t <= n /\ n <= maxint t | false |
Spec.AES.Test.fst | Spec.AES.Test.test4_output_ciphertext | val test4_output_ciphertext:lbytes 16 | val test4_output_ciphertext:lbytes 16 | let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 303,
"start_col": 0,
"start_line": 298
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test4_output_ciphertext:lbytes 16 =
| let l =
List.Tot.map u8_from_UInt8
[
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy; 0x74uy; 0x3buy; 0x94uy; 0xd5uy;
0x00uy; 0x2auy; 0x12uy; 0x6buy
]
in
assert_norm (List.Tot.length l == 16);
of_list l | false |
Spec.AES.Test.fst | Spec.AES.Test.test_one_encrypt | val test_one_encrypt : v: Spec.AES.Test.vec -> FStar.All.ALL Prims.bool | let test_one_encrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> expected
| Vec_block v key plain expected -> expected in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter plain
| Vec_block v key plain expected ->
aes_encrypt_block v (aes_key_expansion v key) plain in
PS.print_compare true (length expected) computed expected | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 371,
"start_col": 0,
"start_line": 358
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n"
(*
let seqsbox_16 = map (fun s -> sbox_bp_16 s) seqi in
IO.print_string "sbox bp_i i:\n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox_16);
IO.print_string "\n";
*)
noeq type vec =
| Vec :
v:variant
-> key:aes_key v
-> nonce:bytes{length nonce <= 16}
-> c:size_nat
-> msg:bytes{length msg / 16 + c <= max_size_t}
-> expected:bytes{length msg = length expected /\ length msg <= max_size_t} -> vec
| Vec_block :
v:variant
-> key:aes_key v
-> plain:block
-> expected:block -> vec
let test_vectors : list vec = [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
]
#set-options "--ifuel 1" | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v: Spec.AES.Test.vec -> FStar.All.ALL Prims.bool | FStar.All.ALL | [] | [] | [
"Spec.AES.Test.vec",
"Lib.PrintSequence.print_compare",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.bool",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Spec.AES.variant",
"Spec.AES.aes_key",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.size_nat",
"Prims.op_Addition",
"Prims.op_Division",
"Lib.IntTypes.max_size_t",
"Prims.l_and",
"Prims.op_Equality",
"Prims.nat",
"Spec.AES.aes_ctr_encrypt_bytes",
"Spec.AES.block",
"Spec.AES.aes_encrypt_block",
"Spec.AES.aes_key_expansion",
"Lib.ByteSequence.lbytes",
"Lib.Sequence.seq"
] | [] | false | true | false | false | false | let test_one_encrypt (v: vec) =
| let expected =
match v with
| Vec v key nonce counter plain expected -> expected
| Vec_block v key plain expected -> expected
in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter plain
| Vec_block v key plain expected -> aes_encrypt_block v (aes_key_expansion v key) plain
in
PS.print_compare true (length expected) computed expected | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.uint_t | val uint_t : t: Lib.IntTypes.inttype{Lib.IntTypes.unsigned t} -> l: Lib.IntTypes.secrecy_level -> Type0 | let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 64,
"end_line": 158,
"start_col": 0,
"start_line": 158
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Lib.IntTypes.inttype{Lib.IntTypes.unsigned t} -> l: Lib.IntTypes.secrecy_level -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.int_t"
] | [] | false | false | false | false | true | let uint_t (t: inttype{unsigned t}) (l: secrecy_level) =
| int_t t l | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.sint_t | val sint_t : t: Lib.IntTypes.inttype{Lib.IntTypes.signed t} -> l: Lib.IntTypes.secrecy_level -> Type0 | let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 161,
"start_col": 0,
"start_line": 161
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Lib.IntTypes.inttype{Lib.IntTypes.signed t} -> l: Lib.IntTypes.secrecy_level -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.signed",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.int_t"
] | [] | false | false | false | false | true | let sint_t (t: inttype{signed t}) (l: secrecy_level) =
| int_t t l | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.bits | val bits : _: Lib.IntTypes.inttype -> Prims.int | let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 69,
"start_col": 0,
"start_line": 58
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Lib.IntTypes.inttype -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.int"
] | [] | false | false | false | true | false | let bits =
| function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128 | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.uint | val uint : n: Lib.IntTypes.range_t t -> u122: Lib.IntTypes.int_t t l {Lib.IntTypes.v u122 == n} | let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 83,
"end_line": 257,
"start_col": 0,
"start_line": 257
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t t -> u122: Lib.IntTypes.int_t t l {Lib.IntTypes.v u122 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.range_t",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let uint (#t: inttype{unsigned t}) (#l: secrecy_level) (n: range_t t) =
| mk_int #t #l n | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.uint_v | val uint_v : u104: Lib.IntTypes.uint_t t l -> x: Prims.int{Lib.IntTypes.range x t} | let uint_v #t #l (u:uint_t t l) = v u | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 164,
"start_col": 0,
"start_line": 164
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | u104: Lib.IntTypes.uint_t t l -> x: Prims.int{Lib.IntTypes.range x t} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.v",
"Prims.int",
"Lib.IntTypes.range"
] | [] | false | false | false | false | false | let uint_v #t #l (u: uint_t t l) =
| v u | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.sint_v | val sint_v : u110: Lib.IntTypes.sint_t t l -> x: Prims.int{Lib.IntTypes.range x t} | let sint_v #t #l (u:sint_t t l) = v u | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 167,
"start_col": 0,
"start_line": 167
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | u110: Lib.IntTypes.sint_t t l -> x: Prims.int{Lib.IntTypes.range x t} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.signed",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.sint_t",
"Lib.IntTypes.v",
"Prims.int",
"Lib.IntTypes.range"
] | [] | false | false | false | false | false | let sint_v #t #l (u: sint_t t l) =
| v u | false |
|
Hacl.Spec.K256.ECSM.Lemmas.fst | Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_mul_lemma | val aff_point_mul_mul_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (aff_point_mul b p) == aff_point_mul b (aff_point_mul a p)) | val aff_point_mul_mul_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (aff_point_mul b p) == aff_point_mul b (aff_point_mul a p)) | let aff_point_mul_mul_lemma a b p =
calc (==) {
aff_point_mul a (aff_point_mul b p);
(==) { LE.lemma_pow_mul S.mk_k256_comm_monoid p b a }
aff_point_mul (a * b) p;
(==) { LE.lemma_pow_mul S.mk_k256_comm_monoid p a b }
aff_point_mul b (aff_point_mul a p);
} | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 118,
"start_col": 0,
"start_line": 111
} | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a
let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a
assume
val lemma_order_of_curve_group (p:S.aff_point) :
Lemma (aff_point_mul S.q p == S.aff_point_at_inf)
(**
Properties for Elliptic Curve Scalar Multiplication in affine coordinates
*)
// [a + b]P = [a]P + [b]P
val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p))
let lemma_aff_point_mul_neg_add a b p =
LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b
// [a * b]P = [b]([a]P)
val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p))
let lemma_aff_point_mul_neg_mul a b p =
LE.lemma_pow_neg_mul S.mk_k256_abelian_group p a b
// [a * b + c]P = [b]([a]P) + [c]P
val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p))
let lemma_aff_point_mul_neg_mul_add a b c p =
lemma_aff_point_mul_neg_add (a * b) c p;
lemma_aff_point_mul_neg_mul a b p
// [a]P = [a % S.q]P
val lemma_aff_point_mul_neg_modq (a:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg a p == aff_point_mul (a % S.q) p)
let lemma_aff_point_mul_neg_modq a p =
calc (==) {
aff_point_mul_neg a p;
(==) { Math.Lemmas.euclidean_division_definition a S.q }
aff_point_mul_neg (a / S.q * S.q + a % S.q) p;
(==) { lemma_aff_point_mul_neg_add (a / S.q * S.q) (a % S.q) p }
S.aff_point_add (aff_point_mul_neg (a / S.q * S.q) p) (aff_point_mul_neg (a % S.q) p);
(==) { lemma_aff_point_mul_neg_mul (a / S.q) S.q p }
S.aff_point_add
(aff_point_mul S.q (aff_point_mul_neg (a / S.q) p))
(aff_point_mul (a % S.q) p);
(==) { lemma_order_of_curve_group (aff_point_mul_neg (a / S.q) p) }
S.aff_point_add S.aff_point_at_inf (aff_point_mul (a % S.q) p);
(==) { LS.aff_point_add_comm_lemma S.aff_point_at_inf (aff_point_mul (a % S.q) p) }
S.aff_point_add (aff_point_mul (a % S.q) p) S.aff_point_at_inf;
(==) { LS.aff_point_at_inf_lemma (aff_point_mul (a % S.q) p) }
aff_point_mul (a % S.q) p;
}
// [a]P = [(-a) % q](-P)
val lemma_aff_point_mul_neg: a:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul ((- a) % S.q) (S.aff_point_negate p) == aff_point_mul a p)
let lemma_aff_point_mul_neg a p =
let cm = S.mk_k256_comm_monoid in
let ag = S.mk_k256_abelian_group in
let p_neg = S.aff_point_negate p in
if a > 0 then begin
calc (==) {
aff_point_mul ((- a) % S.q) p_neg;
(==) { lemma_aff_point_mul_neg_modq (- a) p_neg }
aff_point_mul_neg (- a) p_neg;
(==) { }
S.aff_point_negate (aff_point_mul a p_neg);
(==) { LE.lemma_inverse_pow ag p a }
S.aff_point_negate (S.aff_point_negate (aff_point_mul a p));
(==) { LE.lemma_inverse_id ag (aff_point_mul a p) }
aff_point_mul a p;
} end
else begin
LE.lemma_pow0 cm p;
LE.lemma_pow0 cm p_neg end
//--------------------------------------------
// [a]([b]P) = [b]([a]P)
val aff_point_mul_mul_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (aff_point_mul b p) == aff_point_mul b (aff_point_mul a p)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Prims.nat -> b: Prims.nat -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul a (Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul b p) ==
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul b (Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul a p)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Spec.K256.PointOps.aff_point",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Mul.op_Star",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Lib.Exponentiation.Definition.lemma_pow_mul",
"Spec.K256.mk_k256_comm_monoid",
"Prims.squash"
] | [] | false | false | true | false | false | let aff_point_mul_mul_lemma a b p =
| calc ( == ) {
aff_point_mul a (aff_point_mul b p);
( == ) { LE.lemma_pow_mul S.mk_k256_comm_monoid p b a }
aff_point_mul (a * b) p;
( == ) { LE.lemma_pow_mul S.mk_k256_comm_monoid p a b }
aff_point_mul b (aff_point_mul a p);
} | false |
Lib.IntTypes.fsti | Lib.IntTypes.sint | val sint : n: Lib.IntTypes.range_t t -> u128: Lib.IntTypes.int_t t l {Lib.IntTypes.v u128 == n} | let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 81,
"end_line": 260,
"start_col": 0,
"start_line": 260
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t t -> u128: Lib.IntTypes.int_t t l {Lib.IntTypes.v u128 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.signed",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.range_t",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let sint (#t: inttype{signed t}) (#l: secrecy_level) (n: range_t t) =
| mk_int #t #l n | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.numbytes | val numbytes : _: Lib.IntTypes.inttype -> Prims.int | let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 53,
"start_col": 0,
"start_line": 42
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Lib.IntTypes.inttype -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.int"
] | [] | false | false | false | true | false | let numbytes =
| function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16 | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.u1 | val u1 (n: range_t U1) : u: uint1{v u == n} | val u1 (n: range_t U1) : u: uint1{v u == n} | let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 271,
"start_col": 0,
"start_line": 271
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t Lib.IntTypes.U1 -> u134: Lib.IntTypes.uint1{Lib.IntTypes.v u134 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U1",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint1",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let u1 (n: range_t U1) : u: uint1{v u == n} =
| uint #U1 #SEC n | false |
Spec.AES.Test.fst | Spec.AES.Test.test_one_decrypt | val test_one_decrypt : v: Spec.AES.Test.vec -> FStar.All.ALL Prims.bool | let test_one_decrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> plain
| Vec_block v key plain expected -> plain in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter expected
| Vec_block v key plain expected ->
aes_decrypt_block v (aes_dec_key_expansion v key) expected in
PS.print_compare true (length expected) computed expected | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 387,
"start_col": 0,
"start_line": 374
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n"
(*
let seqsbox_16 = map (fun s -> sbox_bp_16 s) seqi in
IO.print_string "sbox bp_i i:\n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox_16);
IO.print_string "\n";
*)
noeq type vec =
| Vec :
v:variant
-> key:aes_key v
-> nonce:bytes{length nonce <= 16}
-> c:size_nat
-> msg:bytes{length msg / 16 + c <= max_size_t}
-> expected:bytes{length msg = length expected /\ length msg <= max_size_t} -> vec
| Vec_block :
v:variant
-> key:aes_key v
-> plain:block
-> expected:block -> vec
let test_vectors : list vec = [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
]
#set-options "--ifuel 1"
let test_one_encrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> expected
| Vec_block v key plain expected -> expected in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter plain
| Vec_block v key plain expected ->
aes_encrypt_block v (aes_key_expansion v key) plain in
PS.print_compare true (length expected) computed expected | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v: Spec.AES.Test.vec -> FStar.All.ALL Prims.bool | FStar.All.ALL | [] | [] | [
"Spec.AES.Test.vec",
"Lib.PrintSequence.print_compare",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.bool",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Spec.AES.variant",
"Spec.AES.aes_key",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.size_nat",
"Prims.op_Addition",
"Prims.op_Division",
"Lib.IntTypes.max_size_t",
"Prims.l_and",
"Prims.op_Equality",
"Prims.nat",
"Spec.AES.aes_ctr_encrypt_bytes",
"Spec.AES.block",
"Spec.AES.aes_decrypt_block",
"Spec.AES.aes_dec_key_expansion",
"Lib.ByteSequence.lbytes",
"Lib.Sequence.seq"
] | [] | false | true | false | false | false | let test_one_decrypt (v: vec) =
| let expected =
match v with
| Vec v key nonce counter plain expected -> plain
| Vec_block v key plain expected -> plain
in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter expected
| Vec_block v key plain expected -> aes_decrypt_block v (aes_dec_key_expansion v key) expected
in
PS.print_compare true (length expected) computed expected | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.modulus | val modulus : t: Lib.IntTypes.inttype -> Prims.pos | let modulus (t:inttype) = pow2 (bits t) | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 75,
"start_col": 0,
"start_line": 75
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Lib.IntTypes.inttype -> Prims.pos | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.pow2",
"Lib.IntTypes.bits",
"Prims.pos"
] | [] | false | false | false | true | false | let modulus (t: inttype) =
| pow2 (bits t) | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.u8 | val u8 (n: range_t U8) : u: uint8{v u == n} | val u8 (n: range_t U8) : u: uint8{v u == n} | let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 274,
"start_col": 0,
"start_line": 274
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t Lib.IntTypes.U8 -> u136: Lib.IntTypes.uint8{Lib.IntTypes.v u136 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint8",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let u8 (n: range_t U8) : u: uint8{v u == n} =
| uint #U8 #SEC n | false |
Spec.AES.Test.fst | Spec.AES.Test.test | val test: Prims.unit -> FStar.All.ML bool | val test: Prims.unit -> FStar.All.ML bool | let test() : FStar.All.ML bool =
// print_sbox (); // TODO: rm?
IO.print_string "\n\nAES Encryption\n";
let res_enc = List.for_all (fun (v:vec) -> test_one_encrypt v) test_vectors in
IO.print_string "\n\nAES Decryption\n";
let res_dec = List.for_all (fun (v:vec) -> test_one_decrypt v) test_vectors in
IO.print_string "\n\nAES Key Expansion\n";
let computed1 = aes_key_expansion AES256 test1_input_key1 in
let res_key = PS.print_compare true (length computed1) test1_output_expanded computed1 in
let res = res_enc && res_dec && res_key in
if res then begin IO.print_string "\n\nAES: Success!\n"; true end
else begin IO.print_string "\n\nAES: Failure :(\n"; false end | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 403,
"start_col": 0,
"start_line": 390
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l
let test2_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test2_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x11uy; 0x22uy; 0x33uy; 0x44uy; 0x55uy; 0x66uy; 0x77uy;
0x88uy; 0x99uy; 0xaauy; 0xbbuy; 0xccuy; 0xdduy; 0xeeuy; 0xffuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x8euy; 0xa2uy; 0xb7uy; 0xcauy; 0x51uy; 0x67uy; 0x45uy; 0xbfuy;
0xeauy; 0xfcuy; 0x49uy; 0x90uy; 0x4buy; 0x49uy; 0x60uy; 0x89uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xc4uy; 0x7buy; 0x02uy; 0x94uy; 0xdbuy; 0xbbuy; 0xeeuy; 0x0fuy;
0xecuy; 0x47uy; 0x57uy; 0xf2uy; 0x2fuy; 0xfeuy; 0xeeuy; 0x35uy;
0x87uy; 0xcauy; 0x47uy; 0x30uy; 0xc3uy; 0xd3uy; 0x3buy; 0x69uy;
0x1duy; 0xf3uy; 0x8buy; 0xabuy; 0x07uy; 0x6buy; 0xc5uy; 0x58uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test3_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x46uy; 0xf2uy; 0xfbuy; 0x34uy; 0x2duy; 0x6fuy; 0x0auy; 0xb4uy;
0x77uy; 0x47uy; 0x6fuy; 0xc5uy; 0x01uy; 0x24uy; 0x2cuy; 0x5fuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_input_key : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0xccuy; 0xd1uy; 0xbcuy; 0x3cuy; 0x65uy; 0x9cuy; 0xd3uy; 0xc5uy;
0x9buy; 0xc4uy; 0x37uy; 0x48uy; 0x4euy; 0x3cuy; 0x5cuy; 0x72uy;
0x44uy; 0x41uy; 0xdauy; 0x8duy; 0x6euy; 0x90uy; 0xceuy; 0x55uy;
0x6cuy; 0xd5uy; 0x7duy; 0x07uy; 0x52uy; 0x66uy; 0x3buy; 0xbcuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test4_input_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test4_output_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x30uy; 0x4fuy; 0x81uy; 0xabuy; 0x61uy; 0xa8uy; 0x0cuy; 0x2euy;
0x74uy; 0x3buy; 0x94uy; 0xd5uy; 0x00uy; 0x2auy; 0x12uy; 0x6buy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let print_sbox () : FStar.All.ML unit =
let seq = create 256 (u8 0) in
let seqi = Lib.LoopCombinators.repeati #(lseq uint8 256) 256 (fun i s -> s.[i] <- u8 i) seq in
(*
let inv = map (fun s -> from_elem (finv (to_elem s))) seqi in
IO.print_string "inv i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 #256 inv);
IO.print_string "\n";
*)
let seqsbox = map (fun s -> sub_byte s) seqi in
IO.print_string "sbox i: \n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox);
IO.print_string "\n"
(*
let seqsbox_16 = map (fun s -> sbox_bp_16 s) seqi in
IO.print_string "sbox bp_i i:\n";
FStar.List.iter (fun a -> IO.print_string (UInt8.to_string (u8_to_UInt8 a)); IO.print_string " ; ") (to_list #uint8 seqsbox_16);
IO.print_string "\n";
*)
noeq type vec =
| Vec :
v:variant
-> key:aes_key v
-> nonce:bytes{length nonce <= 16}
-> c:size_nat
-> msg:bytes{length msg / 16 + c <= max_size_t}
-> expected:bytes{length msg = length expected /\ length msg <= max_size_t} -> vec
| Vec_block :
v:variant
-> key:aes_key v
-> plain:block
-> expected:block -> vec
let test_vectors : list vec = [
Vec AES128 test_key test_nonce test_counter test_plaintext test_ciphertext;
Vec AES128 test_key1 test_nonce1 test_counter1 test_plaintext1 test_ciphertext1;
Vec AES128 test_key2 test_nonce2 test_counter2 test_plaintext2 test_ciphertext2;
Vec_block AES128 test1_key_block test1_plaintext_block test1_ciphertext_block;
Vec_block AES128 test2_key_block test2_plaintext_block test2_ciphertext_block;
Vec_block AES128 test3_key_block test2_plaintext_block test3_ciphertext_block;
Vec_block AES256 test2_input_key test2_input_plaintext test2_output_ciphertext;
Vec_block AES256 test3_input_key test3_input_plaintext test3_output_ciphertext;
Vec_block AES256 test4_input_key test4_input_plaintext test4_output_ciphertext
]
#set-options "--ifuel 1"
let test_one_encrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> expected
| Vec_block v key plain expected -> expected in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter plain
| Vec_block v key plain expected ->
aes_encrypt_block v (aes_key_expansion v key) plain in
PS.print_compare true (length expected) computed expected
let test_one_decrypt (v:vec) =
let expected =
match v with
| Vec v key nonce counter plain expected -> plain
| Vec_block v key plain expected -> plain in
let computed =
match v with
| Vec v key nonce counter plain expected ->
aes_ctr_encrypt_bytes v key (length nonce) nonce counter expected
| Vec_block v key plain expected ->
aes_decrypt_block v (aes_dec_key_expansion v key) expected in
PS.print_compare true (length expected) computed expected | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.All.ML Prims.bool | FStar.All.ML | [
"ml"
] | [] | [
"Prims.unit",
"Prims.bool",
"FStar.IO.print_string",
"Prims.op_AmpAmp",
"Lib.PrintSequence.print_compare",
"Lib.Sequence.length",
"Spec.AES.elem",
"Spec.AES.Test.test1_output_expanded",
"Spec.AES.aes_xkey",
"Spec.AES.AES256",
"Spec.AES.aes_key_expansion",
"Spec.AES.Test.test1_input_key1",
"FStar.List.for_all",
"Spec.AES.Test.vec",
"Spec.AES.Test.test_one_decrypt",
"Spec.AES.Test.test_vectors",
"Spec.AES.Test.test_one_encrypt"
] | [] | false | true | false | false | false | let test () : FStar.All.ML bool =
| IO.print_string "\n\nAES Encryption\n";
let res_enc = List.for_all (fun (v: vec) -> test_one_encrypt v) test_vectors in
IO.print_string "\n\nAES Decryption\n";
let res_dec = List.for_all (fun (v: vec) -> test_one_decrypt v) test_vectors in
IO.print_string "\n\nAES Key Expansion\n";
let computed1 = aes_key_expansion AES256 test1_input_key1 in
let res_key = PS.print_compare true (length computed1) test1_output_expanded computed1 in
let res = res_enc && res_dec && res_key in
if res
then
(IO.print_string "\n\nAES: Success!\n";
true)
else
(IO.print_string "\n\nAES: Failure :(\n";
false) | false |
Lib.IntTypes.fsti | Lib.IntTypes.minint | val minint : t: Lib.IntTypes.inttype -> Prims.int | let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1)) | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 85,
"start_col": 0,
"start_line": 84
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Lib.IntTypes.inttype -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.unsigned",
"Prims.bool",
"Prims.op_Minus",
"Prims.pow2",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"Prims.int"
] | [] | false | false | false | true | false | let minint (t: inttype) =
| if unsigned t then 0 else - (pow2 (bits t - 1)) | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.maxint | val maxint : t: Lib.IntTypes.inttype -> Prims.int | let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 80,
"start_col": 0,
"start_line": 79
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Lib.IntTypes.inttype -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.unsigned",
"Prims.op_Subtraction",
"Prims.pow2",
"Lib.IntTypes.bits",
"Prims.bool",
"Prims.int"
] | [] | false | false | false | true | false | let maxint (t: inttype) =
| if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1 | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.i8 | val i8 (n: range_t S8) : u: int8{v u == n} | val i8 (n: range_t S8) : u: int8{v u == n} | let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 277,
"start_col": 0,
"start_line": 277
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t Lib.IntTypes.S8 -> u138: Lib.IntTypes.int8{Lib.IntTypes.v u138 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.S8",
"Lib.IntTypes.sint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int8",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let i8 (n: range_t S8) : u: int8{v u == n} =
| sint #S8 #SEC n | false |
Lib.IntTypes.fsti | Lib.IntTypes.int_t | val int_t : t: Lib.IntTypes.inttype -> l: Lib.IntTypes.secrecy_level -> Type0 | let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 149,
"start_col": 0,
"start_line": 146
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
/// | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Lib.IntTypes.inttype -> l: Lib.IntTypes.secrecy_level -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.pub_int_t",
"Lib.IntTypes.sec_int_t"
] | [] | false | false | false | true | true | let int_t (t: inttype) (l: secrecy_level) =
| match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.u16 | val u16 (n: range_t U16) : u: uint16{v u == n} | val u16 (n: range_t U16) : u: uint16{v u == n} | let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 280,
"start_col": 0,
"start_line": 280
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t Lib.IntTypes.U16 -> u140: Lib.IntTypes.uint16{Lib.IntTypes.v u140 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint16",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let u16 (n: range_t U16) : u: uint16{v u == n} =
| uint #U16 #SEC n | false |
Lib.IntTypes.fsti | Lib.IntTypes.pub_int_v | val pub_int_v (#t: _) (x: pub_int_t t) : range_t t | val pub_int_v (#t: _) (x: pub_int_t t) : range_t t | let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 126,
"start_col": 0,
"start_line": 114
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Lib.IntTypes.pub_int_t t -> Lib.IntTypes.range_t t | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.pub_int_t",
"FStar.UInt8.v",
"FStar.UInt16.v",
"FStar.UInt32.v",
"FStar.UInt64.v",
"FStar.UInt128.v",
"FStar.Int8.v",
"FStar.Int16.v",
"FStar.Int32.v",
"FStar.Int64.v",
"FStar.Int128.v",
"Lib.IntTypes.range_t"
] | [] | false | false | false | false | false | let pub_int_v #t (x: pub_int_t t) : range_t t =
| match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x | false |
Lib.IntTypes.fsti | Lib.IntTypes.v | val v (#t #l: _) (u: int_t t l) : range_t t | val v (#t #l: _) (u: int_t t l) : range_t t | let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 155,
"start_col": 0,
"start_line": 152
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | u90: Lib.IntTypes.int_t t l -> Lib.IntTypes.range_t t | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.int_t",
"Lib.IntTypes.pub_int_v",
"Lib.IntTypes.sec_int_v",
"Lib.IntTypes.range_t"
] | [] | false | false | false | false | false | let v #t #l (u: int_t t l) : range_t t =
| match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u | false |
Lib.IntTypes.fsti | Lib.IntTypes.pub_int_t | val pub_int_t : _: Lib.IntTypes.inttype -> Type0 | let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 109,
"start_col": 0,
"start_line": 98
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
/// | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Lib.IntTypes.inttype -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"FStar.UInt8.t",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt8.v",
"FStar.UInt16.t",
"FStar.UInt32.t",
"FStar.UInt64.t",
"FStar.UInt128.t",
"FStar.Int8.t",
"FStar.Int16.t",
"FStar.Int32.t",
"FStar.Int64.t",
"FStar.Int128.t"
] | [] | false | false | false | true | true | let pub_int_t =
| function
| U1 -> n: UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t | false |
|
Spec.AES.Test.fst | Spec.AES.Test.test1_output_expanded | val test1_output_expanded:lbytes 240 | val test1_output_expanded:lbytes 240 | let test1_output_expanded : lbytes 240 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy;
0x9buy; 0xa3uy; 0x54uy; 0x11uy; 0x8euy; 0x69uy; 0x25uy; 0xafuy;
0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy;
0xbeuy; 0x49uy; 0x84uy; 0x6euy; 0xb7uy; 0x5duy; 0x5buy; 0x9auy;
0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy;
0xb5uy; 0xa9uy; 0x32uy; 0x8auy; 0x26uy; 0x78uy; 0xa6uy; 0x47uy;
0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy;
0x24uy; 0x36uy; 0x0auy; 0xf2uy; 0xfauy; 0xb8uy; 0xb4uy; 0x64uy;
0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy;
0x68uy; 0x00uy; 0x7buy; 0xacuy; 0xb2uy; 0xdfuy; 0x33uy; 0x16uy;
0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy;
0x50uy; 0x25uy; 0xc0uy; 0x2duy; 0x59uy; 0xc5uy; 0x82uy; 0x39uy;
0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy;
0x58uy; 0x86uy; 0xcauy; 0x5duy; 0x2euy; 0x2fuy; 0x31uy; 0xd7uy;
0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy;
0xe2uy; 0x75uy; 0x7euy; 0x4fuy; 0x74uy; 0x01uy; 0x90uy; 0x5auy;
0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy;
0xfeuy; 0x48uy; 0x90uy; 0xd1uy; 0xe6uy; 0x18uy; 0x8duy; 0x0buy;
0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
] in
assert_norm (List.Tot.length l == 240);
of_list l | {
"file_name": "specs/tests/Spec.AES.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 225,
"start_col": 0,
"start_line": 191
} | module Spec.AES.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module PS = Lib.PrintSequence
open Spec.AES
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let test_key : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x2buy; 0x7euy; 0x15uy; 0x16uy; 0x28uy; 0xaeuy; 0xd2uy; 0xa6uy;
0xabuy; 0xf7uy; 0x15uy; 0x88uy; 0x09uy; 0xcfuy; 0x4fuy; 0x3cuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy;
0xf8uy; 0xf9uy; 0xfauy; 0xfbuy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter = 0xfcfdfeff
let test_plaintext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x6buy; 0xc1uy; 0xbeuy; 0xe2uy; 0x2euy; 0x40uy; 0x9fuy; 0x96uy;
0xe9uy; 0x3duy; 0x7euy; 0x11uy; 0x73uy; 0x93uy; 0x17uy; 0x2auy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x87uy; 0x4duy; 0x61uy; 0x91uy; 0xb6uy; 0x20uy; 0xe3uy; 0x26uy;
0x1buy; 0xefuy; 0x68uy; 0x64uy; 0x99uy; 0x0duy; 0xb6uy; 0xceuy ] in
assert_norm (List.Tot.length l == 16);
of_list l
(* From RFC 3686 *)
let test_key1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xAEuy; 0x68uy; 0x52uy; 0xF8uy; 0x12uy; 0x10uy; 0x67uy; 0xCCuy;
0x4Buy; 0xF7uy; 0xA5uy; 0x76uy; 0x55uy; 0x77uy; 0xF3uy; 0x9Euy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x30uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_counter1 = 1
let test_plaintext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x53uy; 0x69uy; 0x6Euy; 0x67uy; 0x6Cuy; 0x65uy; 0x20uy; 0x62uy;
0x6Cuy; 0x6Fuy; 0x63uy; 0x6Buy; 0x20uy; 0x6Duy; 0x73uy; 0x67uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_ciphertext1 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xE4uy; 0x09uy; 0x5Duy; 0x4Fuy; 0xB7uy; 0xA7uy; 0xB3uy; 0x79uy;
0x2Duy; 0x61uy; 0x75uy; 0xA3uy; 0x26uy; 0x13uy; 0x11uy; 0xB8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_key2 : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x7Euy; 0x24uy; 0x06uy; 0x78uy; 0x17uy; 0xFAuy; 0xE0uy; 0xD7uy;
0x43uy; 0xD6uy; 0xCEuy; 0x1Fuy; 0x32uy; 0x53uy; 0x91uy; 0x63uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test_nonce2 : lbytes 12 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x6Cuy; 0xB6uy; 0xDBuy; 0xC0uy; 0x54uy; 0x3Buy; 0x59uy;
0xDAuy; 0x48uy; 0xD9uy; 0x0Buy ] in
assert_norm (List.Tot.length l == 12);
of_list l
let test_counter2 = 1
let test_plaintext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy;
0x08uy; 0x09uy; 0x0Auy; 0x0Buy; 0x0Cuy; 0x0Duy; 0x0Euy; 0x0Fuy;
0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy;
0x18uy; 0x19uy; 0x1Auy; 0x1Buy; 0x1Cuy; 0x1Duy; 0x1Euy; 0x1Fuy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test_ciphertext2 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x51uy; 0x04uy; 0xA1uy; 0x06uy; 0x16uy; 0x8Auy; 0x72uy; 0xD9uy;
0x79uy; 0x0Duy; 0x41uy; 0xEEuy; 0x8Euy; 0xDAuy; 0xD3uy; 0x88uy;
0xEBuy; 0x2Euy; 0x1Euy; 0xFCuy; 0x46uy; 0xDAuy; 0x57uy; 0xC8uy;
0xFCuy; 0xE6uy; 0x30uy; 0xDFuy; 0x91uy; 0x41uy; 0xBEuy; 0x28uy ] in
assert_norm (List.Tot.length l == 32);
of_list l
let test1_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x80uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x0euy; 0xdduy; 0x33uy; 0xd3uy; 0xc6uy; 0x21uy; 0xe5uy; 0x46uy;
0x45uy; 0x5buy; 0xd8uy; 0xbauy; 0x14uy; 0x18uy; 0xbeuy; 0xc8uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xf0uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_plaintext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test2_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xe6uy; 0xc4uy; 0x80uy; 0x7auy; 0xe1uy; 0x1fuy; 0x36uy; 0xf0uy;
0x91uy; 0xc5uy; 0x7duy; 0x9fuy; 0xb6uy; 0x85uy; 0x48uy; 0xd1uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_key_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xfeuy; 0xffuy; 0xe9uy; 0x92uy; 0x86uy; 0x65uy; 0x73uy; 0x1cuy;
0x6duy; 0x6auy; 0x8fuy; 0x94uy; 0x67uy; 0x30uy; 0x83uy; 0x08uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test3_ciphertext_block : lbytes 16 =
let l = List.Tot.map u8_from_UInt8 [
0xb8uy; 0x3buy; 0x53uy; 0x37uy; 0x08uy; 0xbfuy; 0x53uy; 0x5duy;
0x0auy; 0xa6uy; 0xe5uy; 0x29uy; 0x80uy; 0xd5uy; 0x3buy; 0x78uy ] in
assert_norm (List.Tot.length l == 16);
of_list l
let test1_input_key1 : lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy;
0x2buy; 0x73uy; 0xaeuy; 0xf0uy; 0x85uy; 0x7duy; 0x77uy; 0x81uy;
0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy ] in
assert_norm (List.Tot.length l == 32);
of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.AES.Test.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 240 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let test1_output_expanded:lbytes 240 =
| let l =
List.Tot.map u8_from_UInt8
[
0x60uy; 0x3duy; 0xebuy; 0x10uy; 0x15uy; 0xcauy; 0x71uy; 0xbeuy; 0x2buy; 0x73uy; 0xaeuy; 0xf0uy;
0x85uy; 0x7duy; 0x77uy; 0x81uy; 0x1fuy; 0x35uy; 0x2cuy; 0x07uy; 0x3buy; 0x61uy; 0x08uy; 0xd7uy;
0x2duy; 0x98uy; 0x10uy; 0xa3uy; 0x09uy; 0x14uy; 0xdfuy; 0xf4uy; 0x9buy; 0xa3uy; 0x54uy; 0x11uy;
0x8euy; 0x69uy; 0x25uy; 0xafuy; 0xa5uy; 0x1auy; 0x8buy; 0x5fuy; 0x20uy; 0x67uy; 0xfcuy; 0xdeuy;
0xa8uy; 0xb0uy; 0x9cuy; 0x1auy; 0x93uy; 0xd1uy; 0x94uy; 0xcduy; 0xbeuy; 0x49uy; 0x84uy; 0x6euy;
0xb7uy; 0x5duy; 0x5buy; 0x9auy; 0xd5uy; 0x9auy; 0xecuy; 0xb8uy; 0x5buy; 0xf3uy; 0xc9uy; 0x17uy;
0xfeuy; 0xe9uy; 0x42uy; 0x48uy; 0xdeuy; 0x8euy; 0xbeuy; 0x96uy; 0xb5uy; 0xa9uy; 0x32uy; 0x8auy;
0x26uy; 0x78uy; 0xa6uy; 0x47uy; 0x98uy; 0x31uy; 0x22uy; 0x29uy; 0x2fuy; 0x6cuy; 0x79uy; 0xb3uy;
0x81uy; 0x2cuy; 0x81uy; 0xaduy; 0xdauy; 0xdfuy; 0x48uy; 0xbauy; 0x24uy; 0x36uy; 0x0auy; 0xf2uy;
0xfauy; 0xb8uy; 0xb4uy; 0x64uy; 0x98uy; 0xc5uy; 0xbfuy; 0xc9uy; 0xbeuy; 0xbduy; 0x19uy; 0x8euy;
0x26uy; 0x8cuy; 0x3buy; 0xa7uy; 0x09uy; 0xe0uy; 0x42uy; 0x14uy; 0x68uy; 0x00uy; 0x7buy; 0xacuy;
0xb2uy; 0xdfuy; 0x33uy; 0x16uy; 0x96uy; 0xe9uy; 0x39uy; 0xe4uy; 0x6cuy; 0x51uy; 0x8duy; 0x80uy;
0xc8uy; 0x14uy; 0xe2uy; 0x04uy; 0x76uy; 0xa9uy; 0xfbuy; 0x8auy; 0x50uy; 0x25uy; 0xc0uy; 0x2duy;
0x59uy; 0xc5uy; 0x82uy; 0x39uy; 0xdeuy; 0x13uy; 0x69uy; 0x67uy; 0x6cuy; 0xccuy; 0x5auy; 0x71uy;
0xfauy; 0x25uy; 0x63uy; 0x95uy; 0x96uy; 0x74uy; 0xeeuy; 0x15uy; 0x58uy; 0x86uy; 0xcauy; 0x5duy;
0x2euy; 0x2fuy; 0x31uy; 0xd7uy; 0x7euy; 0x0auy; 0xf1uy; 0xfauy; 0x27uy; 0xcfuy; 0x73uy; 0xc3uy;
0x74uy; 0x9cuy; 0x47uy; 0xabuy; 0x18uy; 0x50uy; 0x1duy; 0xdauy; 0xe2uy; 0x75uy; 0x7euy; 0x4fuy;
0x74uy; 0x01uy; 0x90uy; 0x5auy; 0xcauy; 0xfauy; 0xaauy; 0xe3uy; 0xe4uy; 0xd5uy; 0x9buy; 0x34uy;
0x9auy; 0xdfuy; 0x6auy; 0xceuy; 0xbduy; 0x10uy; 0x19uy; 0x0duy; 0xfeuy; 0x48uy; 0x90uy; 0xd1uy;
0xe6uy; 0x18uy; 0x8duy; 0x0buy; 0x04uy; 0x6duy; 0xf3uy; 0x44uy; 0x70uy; 0x6cuy; 0x63uy; 0x1euy
]
in
assert_norm (List.Tot.length l == 240);
of_list l | false |
Lib.IntTypes.fsti | Lib.IntTypes.u64 | val u64 (n: range_t U64) : u: uint64{v u == n} | val u64 (n: range_t U64) : u: uint64{v u == n} | let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 292,
"start_col": 0,
"start_line": 292
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t Lib.IntTypes.U64 -> u148: Lib.IntTypes.uint64{Lib.IntTypes.v u148 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint64",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let u64 (n: range_t U64) : u: uint64{v u == n} =
| uint #U64 #SEC n | false |
Lib.IntTypes.fsti | Lib.IntTypes.i32 | val i32 (n: range_t S32) : u: int32{v u == n} | val i32 (n: range_t S32) : u: int32{v u == n} | let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 289,
"start_col": 0,
"start_line": 289
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t Lib.IntTypes.S32 -> u146: Lib.IntTypes.int32{Lib.IntTypes.v u146 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.S32",
"Lib.IntTypes.sint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int32",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let i32 (n: range_t S32) : u: int32{v u == n} =
| sint #S32 #SEC n | false |
Lib.IntTypes.fsti | Lib.IntTypes.u32 | val u32 (n: range_t U32) : u: uint32{v u == n} | val u32 (n: range_t U32) : u: uint32{v u == n} | let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 286,
"start_col": 0,
"start_line": 286
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t Lib.IntTypes.U32 -> u144: Lib.IntTypes.uint32{Lib.IntTypes.v u144 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint32",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let u32 (n: range_t U32) : u: uint32{v u == n} =
| uint #U32 #SEC n | false |
Lib.IntTypes.fsti | Lib.IntTypes.i16 | val i16 (n: range_t S16) : u: int16{v u == n} | val i16 (n: range_t S16) : u: int16{v u == n} | let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 283,
"start_col": 0,
"start_line": 283
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t Lib.IntTypes.S16 -> u142: Lib.IntTypes.int16{Lib.IntTypes.v u142 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.S16",
"Lib.IntTypes.sint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int16",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let i16 (n: range_t S16) : u: int16{v u == n} =
| sint #S16 #SEC n | false |
Lib.IntTypes.fsti | Lib.IntTypes.i64 | val i64 (n: range_t S64) : u: int64{v u == n} | val i64 (n: range_t S64) : u: int64{v u == n} | let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 295,
"start_col": 0,
"start_line": 295
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.range_t Lib.IntTypes.S64 -> u150: Lib.IntTypes.int64{Lib.IntTypes.v u150 == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.range_t",
"Lib.IntTypes.S64",
"Lib.IntTypes.sint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int64",
"Prims.eq2",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let i64 (n: range_t S64) : u: int64{v u == n} =
| sint #S64 #SEC n | false |
Lib.IntTypes.fsti | Lib.IntTypes.max_size_t | val max_size_t : Prims.int | let max_size_t = maxint U32 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 305,
"start_col": 0,
"start_line": 305
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.maxint",
"Lib.IntTypes.U32"
] | [] | false | false | false | true | false | let max_size_t =
| maxint U32 | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.size_v | val size_v : s: Lib.IntTypes.size_t -> x: Prims.int{Lib.IntTypes.range x Lib.IntTypes.U32} | let size_v (s:size_t) = v s | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 317,
"start_col": 0,
"start_line": 317
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Lib.IntTypes.size_t -> x: Prims.int{Lib.IntTypes.range x Lib.IntTypes.U32} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_t",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.int",
"Lib.IntTypes.range"
] | [] | false | false | false | false | false | let size_v (s: size_t) =
| v s | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.byte | val byte (n: nat{n < 256}) : b: byte_t{v b == n} | val byte (n: nat{n < 256}) : b: byte_t{v b == n} | let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 64,
"end_line": 320,
"start_col": 0,
"start_line": 320
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{n < 256} -> b: Lib.IntTypes.byte_t{Lib.IntTypes.v b == n} | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.uint",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Lib.IntTypes.byte_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v"
] | [] | false | false | false | false | false | let byte (n: nat{n < 256}) : b: byte_t{v b == n} =
| uint #U8 #PUB n | false |
Lib.IntTypes.fsti | Lib.IntTypes.byte_v | val byte_v (s: byte_t) : n: size_nat{v s == n} | val byte_v (s: byte_t) : n: size_nat{v s == n} | let byte_v (s:byte_t) : n:size_nat{v s == n} = v s | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 323,
"start_col": 0,
"start_line": 323
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Lib.IntTypes.byte_t -> n: Lib.IntTypes.size_nat{Lib.IntTypes.v s == n} | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.byte_t",
"Lib.IntTypes.v",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size_nat",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t"
] | [] | false | false | false | false | false | let byte_v (s: byte_t) : n: size_nat{v s == n} =
| v s | false |
Lib.IntTypes.fsti | Lib.IntTypes.op_At_Percent_Dot | val op_At_Percent_Dot : x: Prims.int -> t: Lib.IntTypes.inttype -> Prims.int | let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t) | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 338,
"start_col": 0,
"start_line": 336
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> t: Lib.IntTypes.inttype -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Lib.IntTypes.inttype",
"Lib.IntTypes.unsigned",
"Prims.op_Modulus",
"Lib.IntTypes.modulus",
"Prims.bool",
"FStar.Int.op_At_Percent"
] | [] | false | false | false | true | false | let ( @%. ) x t =
| if unsigned t then x % modulus t else let open FStar.Int in x @% modulus t | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.size | val size (n: size_nat) : size_t | val size (n: size_nat) : size_t | let size (n:size_nat) : size_t = uint #U32 #PUB n | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 49,
"end_line": 314,
"start_col": 0,
"start_line": 314
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Lib.IntTypes.size_nat -> Lib.IntTypes.size_t | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_nat",
"Lib.IntTypes.uint",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size_t"
] | [] | false | false | false | true | false | let size (n: size_nat) : size_t =
| uint #U32 #PUB n | false |
Lib.IntTypes.fsti | Lib.IntTypes.ones_v | val ones_v : t: Lib.IntTypes.inttype -> Prims.int | let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 405,
"start_col": 0,
"start_line": 402
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Lib.IntTypes.inttype -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.maxint",
"Prims.op_Minus",
"Prims.int"
] | [] | false | false | false | true | false | let ones_v (t: inttype) =
| match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> - 1 | false |
|
Lib.IntTypes.fsti | Lib.IntTypes.shift_left_i | val shift_left_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l | val shift_left_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l | let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 120,
"end_line": 711,
"start_col": 0,
"start_line": 711
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Lib.IntTypes.shiftval t {Lib.IntTypes.unsigned t} -> u455: Lib.IntTypes.uint_t t l
-> Lib.IntTypes.uint_t t l | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.shiftval",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.shift_left"
] | [] | false | false | false | false | false | let shift_left_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l =
| shift_left u s | false |
Lib.IntTypes.fsti | Lib.IntTypes.logxor_v | val logxor_v (#t: inttype) (a b: range_t t) : range_t t | val logxor_v (#t: inttype) (a b: range_t t) : range_t t | let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 547,
"start_col": 0,
"start_line": 544
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Lib.IntTypes.range_t t -> b: Lib.IntTypes.range_t t -> Lib.IntTypes.range_t t | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.range_t",
"FStar.Int.logxor",
"Lib.IntTypes.bits",
"FStar.UInt.logxor"
] | [] | false | false | false | false | false | let logxor_v (#t: inttype) (a b: range_t t) : range_t t =
| match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b | false |
Lib.IntTypes.fsti | Lib.IntTypes.logand_v | val logand_v (#t: inttype) (a b: range_t t) : range_t t | val logand_v (#t: inttype) (a b: range_t t) : range_t t | let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 578,
"start_col": 0,
"start_line": 575
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Lib.IntTypes.range_t t -> b: Lib.IntTypes.range_t t -> Lib.IntTypes.range_t t | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.range_t",
"FStar.Int.logand",
"Lib.IntTypes.bits",
"FStar.UInt.logand"
] | [] | false | false | false | false | false | let logand_v (#t: inttype) (a b: range_t t) : range_t t =
| match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b | false |
Lib.IntTypes.fsti | Lib.IntTypes.shift_right_i | val shift_right_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l | val shift_right_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l | let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 122,
"end_line": 708,
"start_col": 0,
"start_line": 708
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Lib.IntTypes.shiftval t {Lib.IntTypes.unsigned t} -> u447: Lib.IntTypes.uint_t t l
-> Lib.IntTypes.uint_t t l | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.shiftval",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.shift_right"
] | [] | false | false | false | false | false | let shift_right_i (#t: inttype) (#l: secrecy_level) (s: shiftval t {unsigned t}) (u: uint_t t l)
: uint_t t l =
| shift_right u s | false |
Lib.IntTypes.fsti | Lib.IntTypes.rotate_right_i | val rotate_right_i (#t: inttype) (#l: secrecy_level) (s: rotval t {unsigned t}) (u: uint_t t l)
: uint_t t l | val rotate_right_i (#t: inttype) (#l: secrecy_level) (s: rotval t {unsigned t}) (u: uint_t t l)
: uint_t t l | let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 122,
"end_line": 714,
"start_col": 0,
"start_line": 714
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Lib.IntTypes.rotval t {Lib.IntTypes.unsigned t} -> u463: Lib.IntTypes.uint_t t l
-> Lib.IntTypes.uint_t t l | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.rotval",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.rotate_right"
] | [] | false | false | false | false | false | let rotate_right_i (#t: inttype) (#l: secrecy_level) (s: rotval t {unsigned t}) (u: uint_t t l)
: uint_t t l =
| rotate_right u s | false |
Lib.IntTypes.fsti | Lib.IntTypes.logor_v | val logor_v (#t: inttype) (a b: range_t t) : range_t t | val logor_v (#t: inttype) (a b: range_t t) : range_t t | let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 628,
"start_col": 0,
"start_line": 625
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Lib.IntTypes.range_t t -> b: Lib.IntTypes.range_t t -> Lib.IntTypes.range_t t | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.range_t",
"FStar.Int.logor",
"Lib.IntTypes.bits",
"FStar.UInt.logor"
] | [] | false | false | false | false | false | let logor_v (#t: inttype) (a b: range_t t) : range_t t =
| match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b | false |
Lib.IntTypes.fsti | Lib.IntTypes.lognot_v | val lognot_v (#t: inttype) (a: range_t t) : range_t t | val lognot_v (#t: inttype) (a: range_t t) : range_t t | let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 649,
"start_col": 0,
"start_line": 646
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Lib.IntTypes.range_t t -> Lib.IntTypes.range_t t | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.range_t",
"FStar.Int.lognot",
"Lib.IntTypes.bits",
"FStar.UInt.lognot"
] | [] | false | false | false | false | false | let lognot_v (#t: inttype) (a: range_t t) : range_t t =
| match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a | false |
Lib.IntTypes.fsti | Lib.IntTypes.rotate_left_i | val rotate_left_i (#t: inttype) (#l: secrecy_level) (s: rotval t {unsigned t}) (u: uint_t t l)
: uint_t t l | val rotate_left_i (#t: inttype) (#l: secrecy_level) (s: rotval t {unsigned t}) (u: uint_t t l)
: uint_t t l | let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 120,
"end_line": 717,
"start_col": 0,
"start_line": 717
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Lib.IntTypes.rotval t {Lib.IntTypes.unsigned t} -> u471: Lib.IntTypes.uint_t t l
-> Lib.IntTypes.uint_t t l | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.rotval",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.rotate_left"
] | [] | false | false | false | false | false | let rotate_left_i (#t: inttype) (#l: secrecy_level) (s: rotval t {unsigned t}) (u: uint_t t l)
: uint_t t l =
| rotate_left u s | false |
Lib.IntTypes.fsti | Lib.IntTypes.mod_mask | val mod_mask (#t: inttype) (#l: secrecy_level) (m: shiftval t {pow2 (uint_v m) <= maxint t})
: int_t t l | val mod_mask (#t: inttype) (#l: secrecy_level) (m: shiftval t {pow2 (uint_v m) <= maxint t})
: int_t t l | let mod_mask (#t:inttype) (#l:secrecy_level) (m:shiftval t{pow2 (uint_v m) <= maxint t}) : int_t t l =
shift_left_lemma #t #l (mk_int 1) m;
(mk_int 1 `shift_left` m) `sub` mk_int 1 | {
"file_name": "lib/Lib.IntTypes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 808,
"start_col": 0,
"start_line": 806
} | module Lib.IntTypes
open FStar.Mul
#push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 20"
// Other instances frollow from `FStar.UInt.pow2_values` which is in
// scope of every module depending on Lib.IntTypes
val pow2_2: n:nat -> Lemma (pow2 2 = 4) [SMTPat (pow2 n)]
val pow2_3: n:nat -> Lemma (pow2 3 = 8) [SMTPat (pow2 n)]
val pow2_4: n:nat -> Lemma (pow2 4 = 16) [SMTPat (pow2 n)]
val pow2_127: n:nat -> Lemma (pow2 127 = 0x80000000000000000000000000000000) [SMTPat (pow2 n)]
///
/// Definition of machine integer base types
///
type inttype =
| U1 | U8 | U16 | U32 | U64 | U128 | S8 | S16 | S32 | S64 | S128
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let unsigned = function
| U1 | U8 | U16 | U32 | U64 | U128 -> true
| _ -> false
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let signed = function
| S8 | S16 | S32 | S64 | S128 -> true
| _ -> false
///
/// Operations on the underlying machine integer base types
///
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let numbytes = function
| U1 -> 1
| U8 -> 1
| S8 -> 1
| U16 -> 2
| S16 -> 2
| U32 -> 4
| S32 -> 4
| U64 -> 8
| S64 -> 8
| U128 -> 16
| S128 -> 16
[@(strict_on_arguments [0])]
unfold
inline_for_extraction
let bits = function
| U1 -> 1
| U8 -> 8
| S8 -> 8
| U16 -> 16
| S16 -> 16
| U32 -> 32
| S32 -> 32
| U64 -> 64
| S64 -> 64
| U128 -> 128
| S128 -> 128
val bits_numbytes: t:inttype{~(U1? t)} -> Lemma (bits t == 8 * numbytes t)
// [SMTPat [bits t; numbytes t]]
unfold
let modulus (t:inttype) = pow2 (bits t)
[@(strict_on_arguments [0])]
unfold
let maxint (t:inttype) =
if unsigned t then pow2 (bits t) - 1 else pow2 (bits t - 1) - 1
[@(strict_on_arguments [0])]
unfold
let minint (t:inttype) =
if unsigned t then 0 else -(pow2 (bits t - 1))
let range (n:int) (t:inttype) : Type0 =
minint t <= n /\ n <= maxint t
unfold
type range_t (t:inttype) = x:int{range x t}
///
/// PUBLIC Machine Integers
///
inline_for_extraction
let pub_int_t = function
| U1 -> n:UInt8.t{UInt8.v n < 2}
| U8 -> UInt8.t
| U16 -> UInt16.t
| U32 -> UInt32.t
| U64 -> UInt64.t
| U128 -> UInt128.t
| S8 -> Int8.t
| S16 -> Int16.t
| S32 -> Int32.t
| S64 -> Int64.t
| S128 -> Int128.t
[@(strict_on_arguments [0])]
unfold
let pub_int_v #t (x:pub_int_t t) : range_t t =
match t with
| U1 -> UInt8.v x
| U8 -> UInt8.v x
| U16 -> UInt16.v x
| U32 -> UInt32.v x
| U64 -> UInt64.v x
| U128 -> UInt128.v x
| S8 -> Int8.v x
| S16 -> Int16.v x
| S32 -> Int32.v x
| S64 -> Int64.v x
| S128 -> Int128.v x
///
/// SECRET Machine Integers
///
type secrecy_level =
| SEC
| PUB
inline_for_extraction
val sec_int_t: inttype -> Type0
val sec_int_v: #t:inttype -> sec_int_t t -> range_t t
///
/// GENERIC Machine Integers
///
inline_for_extraction
let int_t (t:inttype) (l:secrecy_level) =
match l with
| PUB -> pub_int_t t
| SEC -> sec_int_t t
[@(strict_on_arguments [1])]
let v #t #l (u:int_t t l) : range_t t =
match l with
| PUB -> pub_int_v #t u
| SEC -> sec_int_v #t u
unfold
let uint_t (t:inttype{unsigned t}) (l:secrecy_level) = int_t t l
unfold
let sint_t (t:inttype{signed t}) (l:secrecy_level) = int_t t l
unfold
let uint_v #t #l (u:uint_t t l) = v u
unfold
let sint_v #t #l (u:sint_t t l) = v u
unfold
type uint1 = uint_t U1 SEC
unfold
type uint8 = uint_t U8 SEC
unfold
type int8 = sint_t S8 SEC
unfold
type uint16 = uint_t U16 SEC
unfold
type int16 = sint_t S16 SEC
unfold
type uint32 = uint_t U32 SEC
unfold
type int32 = sint_t S32 SEC
unfold
type uint64 = uint_t U64 SEC
unfold
type int64 = sint_t S64 SEC
unfold
type uint128 = uint_t U128 SEC
unfold
type int128 = sint_t S128 SEC
unfold
type bit_t = uint_t U1 PUB
unfold
type byte_t = uint_t U8 PUB
unfold
type size_t = uint_t U32 PUB
// 2019.7.19: Used only by experimental Blake2b; remove?
unfold
type size128_t = uint_t U128 PUB
unfold
type pub_uint8 = uint_t U8 PUB
unfold
type pub_int8 = sint_t S8 PUB
unfold
type pub_uint16 = uint_t U16 PUB
unfold
type pub_int16 = sint_t S16 PUB
unfold
type pub_uint32 = uint_t U32 PUB
unfold
type pub_int32 = sint_t S32 PUB
unfold
type pub_uint64 = uint_t U64 PUB
unfold
type pub_int64 = sint_t S64 PUB
unfold
type pub_uint128 = uint_t U128 PUB
unfold
type pub_int128 = sint_t S128 PUB
///
/// Casts between mathematical and machine integers
///
inline_for_extraction
val secret: #t:inttype -> x:int_t t PUB -> y:int_t t SEC{v x == v y}
[@(strict_on_arguments [0])]
inline_for_extraction
val mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> u:int_t t l{v u == n}
unfold
let uint (#t:inttype{unsigned t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
unfold
let sint (#t:inttype{signed t}) (#l:secrecy_level) (n:range_t t) = mk_int #t #l n
val v_injective: #t:inttype -> #l:secrecy_level -> a:int_t t l -> Lemma
(mk_int (v #t #l a) == a)
[SMTPat (v #t #l a)]
val v_mk_int: #t:inttype -> #l:secrecy_level -> n:range_t t -> Lemma
(v #t #l (mk_int #t #l n) == n)
[SMTPat (v #t #l (mk_int #t #l n))]
unfold
let u1 (n:range_t U1) : u:uint1{v u == n} = uint #U1 #SEC n
unfold
let u8 (n:range_t U8) : u:uint8{v u == n} = uint #U8 #SEC n
unfold
let i8 (n:range_t S8) : u:int8{v u == n} = sint #S8 #SEC n
unfold
let u16 (n:range_t U16) : u:uint16{v u == n} = uint #U16 #SEC n
unfold
let i16 (n:range_t S16) : u:int16{v u == n} = sint #S16 #SEC n
unfold
let u32 (n:range_t U32) : u:uint32{v u == n} = uint #U32 #SEC n
unfold
let i32 (n:range_t S32) : u:int32{v u == n} = sint #S32 #SEC n
unfold
let u64 (n:range_t U64) : u:uint64{v u == n} = uint #U64 #SEC n
unfold
let i64 (n:range_t S64) : u:int64{v u == n} = sint #S64 #SEC n
(* We only support 64-bit literals, hence the unexpected upper limit *)
inline_for_extraction
val u128: n:range_t U64 -> u:uint128{v #U128 u == n}
inline_for_extraction
val i128 (n:range_t S64) : u:int128{v #S128 u == n}
unfold
let max_size_t = maxint U32
unfold
type size_nat = n:nat{n <= max_size_t}
unfold
type size_pos = n:pos{n <= max_size_t}
unfold
let size (n:size_nat) : size_t = uint #U32 #PUB n
unfold
let size_v (s:size_t) = v s
unfold
let byte (n:nat{n < 256}) : b:byte_t{v b == n} = uint #U8 #PUB n
unfold
let byte_v (s:byte_t) : n:size_nat{v s == n} = v s
inline_for_extraction
val size_to_uint32: s:size_t -> u:uint32{u == u32 (v s)}
inline_for_extraction
val size_to_uint64: s:size_t -> u:uint64{u == u64 (v s)}
inline_for_extraction
val byte_to_uint8: s:byte_t -> u:uint8{u == u8 (v s)}
[@(strict_on_arguments [0])]
inline_for_extraction
let op_At_Percent_Dot x t =
if unsigned t then x % modulus t
else FStar.Int.(x @% modulus t)
// Casting a value to a signed type is implementation-defined when the value can't
// be represented in the new type; e.g. (int8_t)128UL is implementation-defined
// We rule out this case in the type of `u1`
// See 6.3.1.3 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
[@(strict_on_arguments [0;2])]
inline_for_extraction
val cast: #t:inttype -> #l:secrecy_level
-> t':inttype
-> l':secrecy_level{PUB? l \/ SEC? l'}
-> u1:int_t t l{unsigned t' \/ range (v u1) t'}
-> u2:int_t t' l'{v u2 == v u1 @%. t'}
[@(strict_on_arguments [0])]
unfold
let to_u1 #t #l u : uint1 = cast #t #l U1 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u8 #t #l u : uint8 = cast #t #l U8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i8 #t #l u : int8 = cast #t #l S8 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u16 #t #l u : uint16 = cast #t #l U16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i16 #t #l u : int16 = cast #t #l S16 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u32 #t #l u : uint32 = cast #t #l U32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i32 #t #l u : int32 = cast #t #l S32 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u64 #t #l u : uint64 = cast #t #l U64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i64 #t #l u : int64 = cast #t #l S64 SEC u
[@(strict_on_arguments [0])]
unfold
let to_u128 #t #l u : uint128 = cast #t #l U128 SEC u
[@(strict_on_arguments [0])]
unfold
let to_i128 #t #l u : int128 = cast #t #l S128 SEC u
///
/// Bitwise operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
let ones_v (t:inttype) =
match t with
| U1 | U8 | U16 | U32 | U64 | U128 -> maxint t
| S8 | S16 | S32 | S64 | S128 -> -1
[@(strict_on_arguments [0])]
inline_for_extraction
val ones: t:inttype -> l:secrecy_level -> n:int_t t l{v n = ones_v t}
inline_for_extraction
val zeros: t:inttype -> l:secrecy_level -> n:int_t t l{v n = 0}
[@(strict_on_arguments [0])]
inline_for_extraction
val add_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val add_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(v (add_mod a b) == (v a + v b) @%. t)
[SMTPat (v #t #l (add_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val add: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> int_t t l
val add_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a + v b) t}
-> Lemma
(v #t #l (add #t #l a b) == v a + v b)
[SMTPat (v #t #l (add #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val incr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> int_t t l
val incr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{v a < maxint t}
-> Lemma (v (incr a) == v a + 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val mul_mod: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val mul_mod_lemma: #t:inttype{unsigned t /\ ~(U128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (mul_mod a b) == (v a * v b) @%. t)
[SMTPat (v #t #l (mul_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val mul: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> int_t t l
val mul_lemma: #t:inttype{~(U128? t) /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a * v b) t}
-> Lemma (v #t #l (mul #t #l a b) == v a * v b)
[SMTPat (v #t #l (mul #t #l a b))]
inline_for_extraction
val mul64_wide: uint64 -> uint64 -> uint128
val mul64_wide_lemma: a:uint64 -> b:uint64 -> Lemma
(v (mul64_wide a b) == v a * v b)
[SMTPat (v (mul64_wide a b))]
// KB: I'd prefer
// v (mul64_wide a b) = (pow2 (bits t) + v a - v b) % pow2 (bits t)
inline_for_extraction
val mul_s64_wide: int64 -> int64 -> int128
val mul_s64_wide_lemma: a:int64 -> b:int64 -> Lemma
(v (mul_s64_wide a b) == v a * v b)
[SMTPat (v (mul_s64_wide a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub_mod: #t:inttype{unsigned t} -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val sub_mod_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> a:int_t t l -> b:int_t t l
-> Lemma (v (sub_mod a b) == (v a - v b) @%. t)
[SMTPat (v #t #l (sub_mod #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val sub: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> int_t t l
val sub_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l{range (v a - v b) t}
-> Lemma (v (sub a b) == v a - v b)
[SMTPat (v #t #l (sub #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val decr: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> int_t t l
val decr_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> Lemma (v (decr a) == v a - 1)
[@(strict_on_arguments [0])]
inline_for_extraction
val logxor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logxor_lemma: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(a `logxor` (a `logxor` b) == b /\
a `logxor` (b `logxor` a) == b /\
a `logxor` (mk_int #t #l 0) == a)
val logxor_lemma1: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma
(requires range (v a) U1 /\ range (v b) U1)
(ensures range (v (a `logxor` b)) U1)
let logxor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logxor #(bits t) a b
| _ -> UInt.logxor #(bits t) a b
val logxor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logxor` b) == v a `logxor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val logand: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logand_zeros: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` zeros t l) == 0)
val logand_ones: #t:inttype -> #l:secrecy_level -> a:int_t t l ->
Lemma (v (a `logand` ones t l) == v a)
// For backwards compatibility
val logand_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = 0 then v (a `logand` b) == 0 else v (a `logand` b) == v b))
let logand_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logand #(bits t) a b
| _ -> UInt.logand #(bits t) a b
val logand_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logand` b) == v a `logand_v` v b)
//[SMTPat (v (a `logand` b))]
val logand_le:#t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l ->
Lemma (requires True)
(ensures v (logand a b) <= v a /\ v (logand a b) <= v b)
val logand_mask: #t:inttype{unsigned t} -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> m:pos{m < bits t} ->
Lemma
(requires v b == pow2 m - 1)
(ensures v (logand #t #l a b) == v a % pow2 m)
[@(strict_on_arguments [0])]
inline_for_extraction
val logor: #t:inttype -> #l:secrecy_level
-> int_t t l
-> int_t t l
-> int_t t l
val logor_disjoint: #t:inttype{unsigned t} -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> m:nat{m < bits t}
-> Lemma
(requires 0 <= v a /\ v a < pow2 m /\ v b % pow2 m == 0)
(ensures v (a `logor` b) == v a + v b)
//[SMTPat (v (a `logor` b))]
val logor_zeros: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` zeros t l) == v a)
val logor_ones: #t: inttype -> #l: secrecy_level -> a: int_t t l ->
Lemma (v (a `logor` ones t l) == ones_v t)
// For backwards compatibility
val logor_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (a `logor` b) == ones_v t else v (a `logor` b) == v b))
let logor_v (#t:inttype) (a:range_t t) (b:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.logor #(bits t) a b
| _ -> UInt.logor #(bits t) a b
val logor_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:int_t t l
-> Lemma (v (a `logor` b) == v a `logor_v` v b)
[@(strict_on_arguments [0])]
inline_for_extraction
val lognot: #t:inttype -> #l:secrecy_level -> int_t t l -> int_t t l
val lognot_lemma: #t: inttype -> #l: secrecy_level ->
a: int_t t l ->
Lemma
(requires v a = 0 \/ v a = ones_v t)
(ensures (if v a = ones_v t then v (lognot a) == 0 else v (lognot a) == ones_v t))
let lognot_v (#t:inttype) (a:range_t t) : range_t t =
match t with
| S8 | S16 | S32 | S64 | S128 -> Int.lognot #(bits t) a
| _ -> UInt.lognot #(bits t) a
val lognot_spec: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> Lemma (v (lognot a) == lognot_v (v a))
inline_for_extraction
type shiftval (t:inttype) = u:size_t{v u < bits t}
inline_for_extraction
type rotval (t:inttype) = u:size_t{0 < v u /\ v u < bits t}
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_right: #t:inttype -> #l:secrecy_level
-> int_t t l
-> shiftval t
-> int_t t l
val shift_right_lemma: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> b:shiftval t
-> Lemma
(v (shift_right a b) == v a / pow2 (v b))
[SMTPat (v #t #l (shift_right #t #l a b))]
[@(strict_on_arguments [0])]
inline_for_extraction
val shift_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l
-> s:shiftval t
-> Pure (int_t t l)
(requires unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t))
(ensures fun _ -> True)
val shift_left_lemma:
#t:inttype
-> #l:secrecy_level
-> a:int_t t l{unsigned t \/ 0 <= v a}
-> s:shiftval t{unsigned t \/ (0 <= v a /\ v a * pow2 (v s) <= maxint t)}
-> Lemma
(v (shift_left a s) == (v a * pow2 (v s)) @%. t)
[SMTPat (v #t #l (shift_left #t #l a s))]
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_right: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
[@(strict_on_arguments [0])]
inline_for_extraction
val rotate_left: #t:inttype -> #l:secrecy_level
-> a:int_t t l{unsigned t}
-> rotval t
-> int_t t l
inline_for_extraction
let shift_right_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_right u s
inline_for_extraction
let shift_left_i (#t:inttype) (#l:secrecy_level) (s:shiftval t{unsigned t}) (u:uint_t t l) : uint_t t l = shift_left u s
inline_for_extraction
let rotate_right_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_right u s
inline_for_extraction
let rotate_left_i (#t:inttype) (#l:secrecy_level) (s:rotval t{unsigned t}) (u:uint_t t l) : uint_t t l = rotate_left u s
[@(strict_on_arguments [0])]
inline_for_extraction
val ct_abs: #t:inttype{signed t /\ ~(S128? t)} -> #l:secrecy_level
-> a:int_t t l{minint t < v a}
-> b:int_t t l{v b == abs (v a)}
///
/// Masking operators for all machine integers
///
[@(strict_on_arguments [0])]
inline_for_extraction
val eq_mask: #t:inttype{~(S128? t)} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val eq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (eq_mask a b) == ones_v t
else v (eq_mask a b) == 0)
[SMTPat (eq_mask #t a b)]
val eq_mask_logand_lemma:
#t:inttype{~(S128? t)}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC -> Lemma
(if v a = v b then v (c `logand` eq_mask a b) == v c
else v (c `logand` eq_mask a b) == 0)
[SMTPat (c `logand` eq_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val neq_mask: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC
val neq_mask_lemma: #t:inttype{~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a = v b then v (neq_mask a b) == 0
else v (neq_mask a b) == ones_v t)
[SMTPat (neq_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gte_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a >= v b then v (gte_mask a b) == ones_v t
else v (gte_mask a b) == 0)
[SMTPat (gte_mask #t a b)]
val gte_mask_logand_lemma: #t:inttype{unsigned t}
-> a:int_t t SEC
-> b:int_t t SEC
-> c:int_t t SEC
-> Lemma
(if v a >= v b then v (c `logand` gte_mask a b) == v c
else v (c `logand` gte_mask a b) == 0)
[SMTPat (c `logand` gte_mask a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lt_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a < v b then v (lt_mask a b) == ones_v t
else v (lt_mask a b) == 0)
[SMTPat (lt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val gt_mask: #t:inttype{unsigned t} -> int_t t SEC -> b:int_t t SEC -> int_t t SEC
val gt_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a > v b then v (gt_mask a b) == ones_v t
else v (gt_mask a b) == 0)
[SMTPat (gt_mask #t a b)]
[@(strict_on_arguments [0])]
inline_for_extraction
val lte_mask: #t:inttype{unsigned t} -> int_t t SEC -> int_t t SEC -> int_t t SEC
val lte_mask_lemma: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(if v a <= v b then v (lte_mask a b) == ones_v t
else v (lte_mask a b) == 0)
[SMTPat (lte_mask #t a b)]
#push-options "--max_fuel 1"
[@(strict_on_arguments [0])] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Int128.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: Lib.IntTypes.shiftval t {Prims.pow2 (Lib.IntTypes.uint_v m) <= Lib.IntTypes.maxint t}
-> Lib.IntTypes.int_t t l | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.shiftval",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.pow2",
"Lib.IntTypes.uint_v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.maxint",
"Lib.IntTypes.sub",
"Lib.IntTypes.shift_left",
"Lib.IntTypes.mk_int",
"Prims.unit",
"Lib.IntTypes.shift_left_lemma",
"Lib.IntTypes.int_t"
] | [] | false | false | false | false | false | let mod_mask (#t: inttype) (#l: secrecy_level) (m: shiftval t {pow2 (uint_v m) <= maxint t})
: int_t t l =
| shift_left_lemma #t #l (mk_int 1) m;
((mk_int 1) `shift_left` m) `sub` (mk_int 1) | false |
Hacl.HPKE.Interface.AEAD.fsti | Hacl.HPKE.Interface.AEAD.iv | val iv : a: Spec.Agile.AEAD.alg -> Type0 | let iv (a:AEAD.alg) = lbuffer uint8 12ul | {
"file_name": "code/hpke/Hacl.HPKE.Interface.AEAD.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 15,
"start_col": 0,
"start_line": 15
} | module Hacl.HPKE.Interface.AEAD
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
module S = Spec.Agile.HPKE
module AEAD = Spec.Agile.AEAD
inline_for_extraction noextract
let kv (a:AEAD.alg) = lbuffer uint8 (size (AEAD.key_length a)) | {
"checked_file": "/",
"dependencies": [
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.Interface.AEAD.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.AEAD.alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.AEAD.alg",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | true | let iv (a: AEAD.alg) =
| lbuffer uint8 12ul | false |
|
Hacl.Spec.PrecompBaseTable256.fst | Hacl.Spec.PrecompBaseTable256.lemma_mod_pow2_sub | val lemma_mod_pow2_sub: x:nat -> a:nat -> b:nat ->
Lemma (x / pow2 a % pow2 b * pow2 a == x % pow2 (a + b) - x % pow2 a) | val lemma_mod_pow2_sub: x:nat -> a:nat -> b:nat ->
Lemma (x / pow2 a % pow2 b * pow2 a == x % pow2 (a + b) - x % pow2 a) | let lemma_mod_pow2_sub x a b =
calc (==) {
x / pow2 a % pow2 b * pow2 a;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 x a (a + b) }
x % pow2 (a + b) / pow2 a * pow2 a;
(==) { Math.Lemmas.euclidean_division_definition (x % pow2 (a + b)) (pow2 a) }
x % pow2 (a + b) - x % pow2 (a + b) % pow2 a;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 x a (a + b) }
x % pow2 (a + b) - x % pow2 a;
} | {
"file_name": "code/bignum/Hacl.Spec.PrecompBaseTable256.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 23,
"start_col": 0,
"start_line": 14
} | module Hacl.Spec.PrecompBaseTable256
open FStar.Mul
open Lib.IntTypes
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module BD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Spec.PrecompBaseTable256.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.nat -> a: Prims.nat -> b: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
(x / Prims.pow2 a % Prims.pow2 b) * Prims.pow2 a == x % Prims.pow2 (a + b) - x % Prims.pow2 a) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"FStar.Mul.op_Star",
"Prims.op_Modulus",
"Prims.op_Division",
"Prims.pow2",
"Prims.op_Subtraction",
"Prims.op_Addition",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.pow2_modulo_division_lemma_1",
"Prims.squash",
"FStar.Math.Lemmas.euclidean_division_definition",
"FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1"
] | [] | false | false | true | false | false | let lemma_mod_pow2_sub x a b =
| calc ( == ) {
(x / pow2 a % pow2 b) * pow2 a;
( == ) { Math.Lemmas.pow2_modulo_division_lemma_1 x a (a + b) }
(x % pow2 (a + b) / pow2 a) * pow2 a;
( == ) { Math.Lemmas.euclidean_division_definition (x % pow2 (a + b)) (pow2 a) }
x % pow2 (a + b) - x % pow2 (a + b) % pow2 a;
( == ) { Math.Lemmas.pow2_modulo_modulo_lemma_1 x a (a + b) }
x % pow2 (a + b) - x % pow2 a;
} | false |
Hacl.Spec.PrecompBaseTable256.fst | Hacl.Spec.PrecompBaseTable256.exp_pow2_rec_is_exp_pow2 | val exp_pow2_rec_is_exp_pow2: #t:Type -> k:SE.concrete_ops t -> a:t -> b:nat ->
Lemma (exp_pow2_rec k a b == SE.exp_pow2 k a b) | val exp_pow2_rec_is_exp_pow2: #t:Type -> k:SE.concrete_ops t -> a:t -> b:nat ->
Lemma (exp_pow2_rec k a b == SE.exp_pow2 k a b) | let rec exp_pow2_rec_is_exp_pow2 #t k a b =
if b = 0 then Lib.LoopCombinators.eq_repeat0 k.sqr a
else begin
Lib.LoopCombinators.unfold_repeat b k.sqr a (b - 1);
assert (Loops.repeat b k.sqr a == k.sqr (Loops.repeat (b - 1) k.sqr a));
exp_pow2_rec_is_exp_pow2 k a (b - 1) end | {
"file_name": "code/bignum/Hacl.Spec.PrecompBaseTable256.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 44,
"end_line": 101,
"start_col": 0,
"start_line": 96
} | module Hacl.Spec.PrecompBaseTable256
open FStar.Mul
open Lib.IntTypes
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module BD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lemma_mod_pow2_sub x a b =
calc (==) {
x / pow2 a % pow2 b * pow2 a;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 x a (a + b) }
x % pow2 (a + b) / pow2 a * pow2 a;
(==) { Math.Lemmas.euclidean_division_definition (x % pow2 (a + b)) (pow2 a) }
x % pow2 (a + b) - x % pow2 (a + b) % pow2 a;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 x a (a + b) }
x % pow2 (a + b) - x % pow2 a;
}
let lemma_decompose_nat256_as_four_u64 x =
let x0 = x % pow2 64 in
let x1 = x / pow2 64 % pow2 64 in
let x2 = x / pow2 128 % pow2 64 in
let x3' = x / pow2 192 % pow2 64 in
Math.Lemmas.lemma_div_lt x 256 192;
Math.Lemmas.small_mod (x / pow2 192) (pow2 64);
let x3 = x / pow2 192 in
assert (x3 == x3');
calc (==) {
x0 + x1 * pow2 64 + x2 * pow2 128 + x3 * pow2 192;
(==) { }
x0 + x1 * pow2 64 + (x / pow2 128 % pow2 64) * pow2 128 + x / pow2 192 * pow2 192;
(==) { lemma_mod_pow2_sub x 128 64 }
x0 + x1 * pow2 64 + x % pow2 192 - x % pow2 128 + x / pow2 192 * pow2 192;
(==) { Math.Lemmas.euclidean_division_definition x (pow2 192) }
x0 + x1 * pow2 64 - x % pow2 128 + x;
(==) { lemma_mod_pow2_sub x 64 64 }
x;
}
let lemma_point_mul_base_precomp4 #t k a b =
let (b0, b1, b2, b3) = decompose_nat256_as_four_u64 b in
let a_pow2_64 = LE.pow k a (pow2 64) in
let a_pow2_128 = LE.pow k a (pow2 128) in
let a_pow2_192 = LE.pow k a (pow2 192) in
let res = LE.exp_four_fw k a 64 b0 a_pow2_64 b1 a_pow2_128 b2 a_pow2_192 b3 4 in
calc (==) {
LE.exp_four_fw k a 64 b0 a_pow2_64 b1 a_pow2_128 b2 a_pow2_192 b3 4;
(==) { LE.exp_four_fw_lemma k a 64 b0 a_pow2_64 b1 a_pow2_128 b2 a_pow2_192 b3 4 }
k.LE.mul
(k.LE.mul
(k.LE.mul (LE.pow k a b0) (LE.pow k (LE.pow k a (pow2 64)) b1))
(LE.pow k a_pow2_128 b2))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_mul k a (pow2 64) b1 }
k.LE.mul
(k.LE.mul
(k.LE.mul (LE.pow k a b0) (LE.pow k a (b1 * pow2 64)))
(LE.pow k a_pow2_128 b2))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_add k a b0 (b1 * pow2 64) }
k.LE.mul
(k.LE.mul
(LE.pow k a (b0 + b1 * pow2 64))
(LE.pow k (LE.pow k a (pow2 128)) b2))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_mul k a (pow2 128) b2 }
k.LE.mul
(k.LE.mul (LE.pow k a (b0 + b1 * pow2 64)) (LE.pow k a (b2 * pow2 128)))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_add k a (b0 + b1 * pow2 64) (b2 * pow2 128) }
k.LE.mul
(LE.pow k a (b0 + b1 * pow2 64 + b2 * pow2 128))
(LE.pow k (LE.pow k a (pow2 192)) b3);
(==) { LE.lemma_pow_mul k a (pow2 192) b3 }
k.LE.mul
(LE.pow k a (b0 + b1 * pow2 64 + b2 * pow2 128))
(LE.pow k a (b3 * pow2 192));
(==) { LE.lemma_pow_add k a (b0 + b1 * pow2 64 + b2 * pow2 128) (b3 * pow2 192) }
LE.pow k a (b0 + b1 * pow2 64 + b2 * pow2 128 + b3 * pow2 192);
(==) { lemma_decompose_nat256_as_four_u64 b }
LE.pow k a b;
}
//----------------------- | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Spec.PrecompBaseTable256.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 2,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Spec.Exponentiation.concrete_ops t -> a: t -> b: Prims.nat
-> FStar.Pervasives.Lemma
(ensures Hacl.Spec.PrecompBaseTable256.exp_pow2_rec k a b == Spec.Exponentiation.exp_pow2 k a b) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Lib.LoopCombinators.eq_repeat0",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__sqr",
"Prims.bool",
"Hacl.Spec.PrecompBaseTable256.exp_pow2_rec_is_exp_pow2",
"Prims.op_Subtraction",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.LoopCombinators.repeat",
"Lib.LoopCombinators.unfold_repeat"
] | [
"recursion"
] | false | false | true | false | false | let rec exp_pow2_rec_is_exp_pow2 #t k a b =
| if b = 0
then Lib.LoopCombinators.eq_repeat0 k.sqr a
else
(Lib.LoopCombinators.unfold_repeat b k.sqr a (b - 1);
assert (Loops.repeat b k.sqr a == k.sqr (Loops.repeat (b - 1) k.sqr a));
exp_pow2_rec_is_exp_pow2 k a (b - 1)) | false |
Hacl.Spec.PrecompBaseTable256.fst | Hacl.Spec.PrecompBaseTable256.a_pow2_64_lemma | val a_pow2_64_lemma: #t:Type -> k:SE.concrete_ops t -> a:t ->
Lemma (k.SE.to.SE.refl (a_pow2_64 k a) ==
LE.pow k.SE.to.SE.comm_monoid (k.SE.to.SE.refl a) (pow2 64)) | val a_pow2_64_lemma: #t:Type -> k:SE.concrete_ops t -> a:t ->
Lemma (k.SE.to.SE.refl (a_pow2_64 k a) ==
LE.pow k.SE.to.SE.comm_monoid (k.SE.to.SE.refl a) (pow2 64)) | let a_pow2_64_lemma #t k a =
SE.exp_pow2_lemma k a 64;
LE.exp_pow2_lemma k.SE.to.SE.comm_monoid (k.SE.to.SE.refl a) 64 | {
"file_name": "code/bignum/Hacl.Spec.PrecompBaseTable256.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 107,
"start_col": 0,
"start_line": 105
} | module Hacl.Spec.PrecompBaseTable256
open FStar.Mul
open Lib.IntTypes
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module BD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lemma_mod_pow2_sub x a b =
calc (==) {
x / pow2 a % pow2 b * pow2 a;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 x a (a + b) }
x % pow2 (a + b) / pow2 a * pow2 a;
(==) { Math.Lemmas.euclidean_division_definition (x % pow2 (a + b)) (pow2 a) }
x % pow2 (a + b) - x % pow2 (a + b) % pow2 a;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 x a (a + b) }
x % pow2 (a + b) - x % pow2 a;
}
let lemma_decompose_nat256_as_four_u64 x =
let x0 = x % pow2 64 in
let x1 = x / pow2 64 % pow2 64 in
let x2 = x / pow2 128 % pow2 64 in
let x3' = x / pow2 192 % pow2 64 in
Math.Lemmas.lemma_div_lt x 256 192;
Math.Lemmas.small_mod (x / pow2 192) (pow2 64);
let x3 = x / pow2 192 in
assert (x3 == x3');
calc (==) {
x0 + x1 * pow2 64 + x2 * pow2 128 + x3 * pow2 192;
(==) { }
x0 + x1 * pow2 64 + (x / pow2 128 % pow2 64) * pow2 128 + x / pow2 192 * pow2 192;
(==) { lemma_mod_pow2_sub x 128 64 }
x0 + x1 * pow2 64 + x % pow2 192 - x % pow2 128 + x / pow2 192 * pow2 192;
(==) { Math.Lemmas.euclidean_division_definition x (pow2 192) }
x0 + x1 * pow2 64 - x % pow2 128 + x;
(==) { lemma_mod_pow2_sub x 64 64 }
x;
}
let lemma_point_mul_base_precomp4 #t k a b =
let (b0, b1, b2, b3) = decompose_nat256_as_four_u64 b in
let a_pow2_64 = LE.pow k a (pow2 64) in
let a_pow2_128 = LE.pow k a (pow2 128) in
let a_pow2_192 = LE.pow k a (pow2 192) in
let res = LE.exp_four_fw k a 64 b0 a_pow2_64 b1 a_pow2_128 b2 a_pow2_192 b3 4 in
calc (==) {
LE.exp_four_fw k a 64 b0 a_pow2_64 b1 a_pow2_128 b2 a_pow2_192 b3 4;
(==) { LE.exp_four_fw_lemma k a 64 b0 a_pow2_64 b1 a_pow2_128 b2 a_pow2_192 b3 4 }
k.LE.mul
(k.LE.mul
(k.LE.mul (LE.pow k a b0) (LE.pow k (LE.pow k a (pow2 64)) b1))
(LE.pow k a_pow2_128 b2))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_mul k a (pow2 64) b1 }
k.LE.mul
(k.LE.mul
(k.LE.mul (LE.pow k a b0) (LE.pow k a (b1 * pow2 64)))
(LE.pow k a_pow2_128 b2))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_add k a b0 (b1 * pow2 64) }
k.LE.mul
(k.LE.mul
(LE.pow k a (b0 + b1 * pow2 64))
(LE.pow k (LE.pow k a (pow2 128)) b2))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_mul k a (pow2 128) b2 }
k.LE.mul
(k.LE.mul (LE.pow k a (b0 + b1 * pow2 64)) (LE.pow k a (b2 * pow2 128)))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_add k a (b0 + b1 * pow2 64) (b2 * pow2 128) }
k.LE.mul
(LE.pow k a (b0 + b1 * pow2 64 + b2 * pow2 128))
(LE.pow k (LE.pow k a (pow2 192)) b3);
(==) { LE.lemma_pow_mul k a (pow2 192) b3 }
k.LE.mul
(LE.pow k a (b0 + b1 * pow2 64 + b2 * pow2 128))
(LE.pow k a (b3 * pow2 192));
(==) { LE.lemma_pow_add k a (b0 + b1 * pow2 64 + b2 * pow2 128) (b3 * pow2 192) }
LE.pow k a (b0 + b1 * pow2 64 + b2 * pow2 128 + b3 * pow2 192);
(==) { lemma_decompose_nat256_as_four_u64 b }
LE.pow k a b;
}
//-----------------------
#push-options "--fuel 2"
let rec exp_pow2_rec_is_exp_pow2 #t k a b =
if b = 0 then Lib.LoopCombinators.eq_repeat0 k.sqr a
else begin
Lib.LoopCombinators.unfold_repeat b k.sqr a (b - 1);
assert (Loops.repeat b k.sqr a == k.sqr (Loops.repeat (b - 1) k.sqr a));
exp_pow2_rec_is_exp_pow2 k a (b - 1) end
#pop-options | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Spec.PrecompBaseTable256.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Spec.Exponentiation.concrete_ops t -> a: t
-> FStar.Pervasives.Lemma
(ensures
Mkto_comm_monoid?.refl (Mkconcrete_ops?.to k) (Hacl.Spec.PrecompBaseTable256.a_pow2_64 k a) ==
Lib.Exponentiation.Definition.pow (Mkto_comm_monoid?.comm_monoid (Mkconcrete_ops?.to k))
(Mkto_comm_monoid?.refl (Mkconcrete_ops?.to k) a)
(Prims.pow2 64)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Lib.Exponentiation.exp_pow2_lemma",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__to",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__refl",
"Prims.unit",
"Spec.Exponentiation.exp_pow2_lemma"
] | [] | true | false | true | false | false | let a_pow2_64_lemma #t k a =
| SE.exp_pow2_lemma k a 64;
LE.exp_pow2_lemma k.SE.to.SE.comm_monoid (k.SE.to.SE.refl a) 64 | false |
Hacl.HPKE.Interface.AEAD.fsti | Hacl.HPKE.Interface.AEAD.kv | val kv : a: Spec.Agile.AEAD.alg -> Type0 | let kv (a:AEAD.alg) = lbuffer uint8 (size (AEAD.key_length a)) | {
"file_name": "code/hpke/Hacl.HPKE.Interface.AEAD.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 13,
"start_col": 0,
"start_line": 13
} | module Hacl.HPKE.Interface.AEAD
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
module S = Spec.Agile.HPKE
module AEAD = Spec.Agile.AEAD | {
"checked_file": "/",
"dependencies": [
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.Interface.AEAD.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.AEAD.alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.AEAD.alg",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.size",
"Spec.Agile.AEAD.key_length"
] | [] | false | false | false | true | true | let kv (a: AEAD.alg) =
| lbuffer uint8 (size (AEAD.key_length a)) | false |
|
Hacl.HPKE.Interface.AEAD.fsti | Hacl.HPKE.Interface.AEAD.tag | val tag : a: Spec.Agile.AEAD.alg -> Type0 | let tag (a:AEAD.alg) = lbuffer uint8 (size (AEAD.tag_length a)) | {
"file_name": "code/hpke/Hacl.HPKE.Interface.AEAD.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 17,
"start_col": 0,
"start_line": 17
} | module Hacl.HPKE.Interface.AEAD
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
module S = Spec.Agile.HPKE
module AEAD = Spec.Agile.AEAD
inline_for_extraction noextract
let kv (a:AEAD.alg) = lbuffer uint8 (size (AEAD.key_length a))
inline_for_extraction noextract
let iv (a:AEAD.alg) = lbuffer uint8 12ul | {
"checked_file": "/",
"dependencies": [
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.Interface.AEAD.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.AEAD.alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.AEAD.alg",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.size",
"Spec.Agile.AEAD.tag_length"
] | [] | false | false | false | true | true | let tag (a: AEAD.alg) =
| lbuffer uint8 (size (AEAD.tag_length a)) | false |
|
Vale.Transformers.BoundedInstructionEffects.fsti | Vale.Transformers.BoundedInstructionEffects.only_affects | val only_affects (locs: locations) (f: st unit) : GTot Type0 | val only_affects (locs: locations) (f: st unit) : GTot Type0 | let only_affects (locs:locations) (f:st unit) : GTot Type0 =
forall s. {:pattern unchanged_except locs s (run f s)} (
(run f s).ms_ok ==> unchanged_except locs s (run f s)
) | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 47,
"start_col": 0,
"start_line": 44
} | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Machine_s
open Vale.X64.Machine_Semantics_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
module L = FStar.List.Tot
(** A [location_with_value] contains a location and the value it must hold *)
type location_with_value = l:location_eq & location_val_eqt l
(** A [locations_with_values] contains locations and values they must hold *)
type locations_with_values = list location_with_value
(** An [rw_set] contains information about what locations are read and
written by a stateful operation. *)
type rw_set = {
loc_reads: locations;
loc_writes: locations;
loc_constant_writes: locations_with_values;
}
(** [rw_set_of_ins i] returns the read/write sets for the execution of
an instruction. *)
val rw_set_of_ins : i:ins -> rw_set
(** [locations_of_ocmp o] returns the read set for a comparison operator. *)
val locations_of_ocmp : o:ocmp -> locations
(** [unchanged_except exc s1 s2] means all locations that are disjoint
from the exceptions [exc] have the same value in both [s1] and [s2]. *)
let unchanged_except (exceptions:locations) (s1 s2:machine_state) :
GTot Type0 =
(forall (a:location). {:pattern (eval_location a s2)} (
(!!(disjoint_location_from_locations a exceptions) ==>
(eval_location a s1 == eval_location a s2))
))
(** [only_affects locs f] means that running [f] leaves everything | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fsti.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | locs: Vale.Transformers.Locations.locations -> f: Vale.X64.Machine_Semantics_s.st Prims.unit
-> Prims.GTot Type0 | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.Transformers.Locations.locations",
"Vale.X64.Machine_Semantics_s.st",
"Prims.unit",
"Prims.l_Forall",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.l_imp",
"Prims.b2t",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.X64.Machine_Semantics_s.run",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except"
] | [] | false | false | false | false | true | let only_affects (locs: locations) (f: st unit) : GTot Type0 =
| forall s. {:pattern unchanged_except locs s (run f s)}
((run f s).ms_ok ==> unchanged_except locs s (run f s)) | false |
Vale.Transformers.BoundedInstructionEffects.fsti | Vale.Transformers.BoundedInstructionEffects.unchanged_except | val unchanged_except (exceptions: locations) (s1 s2: machine_state) : GTot Type0 | val unchanged_except (exceptions: locations) (s1 s2: machine_state) : GTot Type0 | let unchanged_except (exceptions:locations) (s1 s2:machine_state) :
GTot Type0 =
(forall (a:location). {:pattern (eval_location a s2)} (
(!!(disjoint_location_from_locations a exceptions) ==>
(eval_location a s1 == eval_location a s2))
)) | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 40,
"start_col": 0,
"start_line": 35
} | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Machine_s
open Vale.X64.Machine_Semantics_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
module L = FStar.List.Tot
(** A [location_with_value] contains a location and the value it must hold *)
type location_with_value = l:location_eq & location_val_eqt l
(** A [locations_with_values] contains locations and values they must hold *)
type locations_with_values = list location_with_value
(** An [rw_set] contains information about what locations are read and
written by a stateful operation. *)
type rw_set = {
loc_reads: locations;
loc_writes: locations;
loc_constant_writes: locations_with_values;
}
(** [rw_set_of_ins i] returns the read/write sets for the execution of
an instruction. *)
val rw_set_of_ins : i:ins -> rw_set
(** [locations_of_ocmp o] returns the read set for a comparison operator. *)
val locations_of_ocmp : o:ocmp -> locations
(** [unchanged_except exc s1 s2] means all locations that are disjoint | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fsti.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
exceptions: Vale.Transformers.Locations.locations ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.GTot Type0 | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.Transformers.Locations.locations",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.l_Forall",
"Vale.Transformers.Locations.location",
"Prims.l_imp",
"Prims.b2t",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location"
] | [] | false | false | false | false | true | let unchanged_except (exceptions: locations) (s1 s2: machine_state) : GTot Type0 =
| (forall (a: location). {:pattern (eval_location a s2)}
((!!(disjoint_location_from_locations a exceptions) ==>
(eval_location a s1 == eval_location a s2)))) | false |
EverCrypt.AutoConfig2.fsti | EverCrypt.AutoConfig2.disabler | val disabler : Type0 | let disabler = unit -> Stack unit
(requires (fun _ -> true))
(ensures (fun h0 _ h1 -> B.(modifies (fp ()) h0 h1))) | {
"file_name": "providers/evercrypt/EverCrypt.AutoConfig2.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 63,
"start_col": 0,
"start_line": 61
} | (** This module, unlike the previous attempt at autoconfig, is entirely written
in Low* + Vale, and does not play dirty tricks with global variables. As such,
there is no C implementation for it, only an .fst file.
This module revolves around individual feature flags, which can be selectively
disabled. *)
module EverCrypt.AutoConfig2
open FStar.HyperStack.ST
open EverCrypt.TargetConfig
module B = LowStar.Buffer
(** Each flag can be queried; we cache the results in mutable global variables,
hidden behind an abstract footprint. Calling a getter requires no reasoning
about the abstract footprint from the client. *)
unfold
inline_for_extraction noextract
let getter (flag: bool) = unit -> Stack bool
(requires (fun _ -> true))
(ensures (fun h0 b h1 ->
B.(modifies loc_none h0 h1) /\
(b ==> flag)))
val has_shaext: getter Vale.X64.CPU_Features_s.sha_enabled
val has_aesni: getter Vale.X64.CPU_Features_s.aesni_enabled
val has_pclmulqdq: getter Vale.X64.CPU_Features_s.pclmulqdq_enabled
val has_avx2: getter Vale.X64.CPU_Features_s.avx2_enabled
val has_avx: getter Vale.X64.CPU_Features_s.avx_enabled
val has_bmi2: getter Vale.X64.CPU_Features_s.bmi2_enabled
val has_adx: getter Vale.X64.CPU_Features_s.adx_enabled
val has_sse: getter Vale.X64.CPU_Features_s.sse_enabled
val has_movbe: getter Vale.X64.CPU_Features_s.movbe_enabled
val has_rdrand: getter Vale.X64.CPU_Features_s.rdrand_enabled
(** At the moment, has_avx512 contains the AVX512_F, AVX512_DQ, AVX512_BW and AVX512_VL flags
See Vale.X64.CPU_Features_s for more details. **)
val has_avx512: getter Vale.X64.CPU_Features_s.avx512_enabled
(** A set of functions that modify the global cached results. For this, the
client needs to reason about the abstract footprint. *)
val fp: unit -> GTot B.loc
(* A client that needs to allocate first then call init should use recall before
anything else; this way, the client will be able to derive disjointness of their
allocations and of fp. *)
val recall: unit -> Stack unit
(requires (fun _ -> True))
(ensures (fun h0 _ h1 ->
B.(loc_not_unused_in h1 `loc_includes` (fp ())) /\ h0 == h1))
(* By default, all feature flags are disabled. A client must call init to get
meaningful results from the various has_* functions. *)
val init: unit -> Stack unit
(requires (fun _ -> True))
(ensures (fun h0 _ h1 ->
B.modifies (fp ()) h0 h1)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.AutoConfig2.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt.TargetConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.b2t",
"LowStar.Monotonic.Buffer.modifies",
"EverCrypt.AutoConfig2.fp"
] | [] | false | false | false | true | true | let disabler =
| unit
-> Stack unit
(requires (fun _ -> true))
(ensures (fun h0 _ h1 -> let open B in modifies (fp ()) h0 h1)) | false |
|
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.srel | val srel : a: Type0 -> Type | let srel (a:Type0) = Preorder.preorder (Seq.seq a) | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 57,
"end_line": 31,
"start_col": 7,
"start_line": 31
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type0 -> Type | Prims.Tot | [
"total"
] | [] | [
"FStar.Preorder.preorder",
"FStar.Seq.Base.seq"
] | [] | false | false | false | true | true | let srel (a: Type0) =
| Preorder.preorder (Seq.seq a) | false |
|
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.live_not_unused_in' | val live_not_unused_in' (#a: Type0) (#rrel #rel: srel a) (h: HS.mem) (b: mbuffer a rrel rel)
: Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)] | val live_not_unused_in' (#a: Type0) (#rrel #rel: srel a) (h: HS.mem) (b: mbuffer a rrel rel)
: Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)] | let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 153,
"start_col": 0,
"start_line": 149
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> b: LowStar.Monotonic.Buffer.mbuffer a rrel rel
-> FStar.Pervasives.Lemma
(requires LowStar.Monotonic.Buffer.live h b /\ LowStar.Monotonic.Buffer.unused_in b h)
(ensures Prims.l_False)
[SMTPat (LowStar.Monotonic.Buffer.live h b); SMTPat (LowStar.Monotonic.Buffer.unused_in b h)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowStar.Monotonic.Buffer.srel",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Monotonic.Buffer.live_not_unused_in",
"Prims.unit",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Monotonic.Buffer.unused_in",
"Prims.squash",
"Prims.l_False",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | true | false | true | false | false | let live_not_unused_in' (#a: Type0) (#rrel #rel: srel a) (h: HS.mem) (b: mbuffer a rrel rel)
: Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)] =
| live_not_unused_in h b | false |
EverCrypt.AutoConfig2.fsti | EverCrypt.AutoConfig2.getter | val getter : flag: Prims.bool -> Type0 | let getter (flag: bool) = unit -> Stack bool
(requires (fun _ -> true))
(ensures (fun h0 b h1 ->
B.(modifies loc_none h0 h1) /\
(b ==> flag))) | {
"file_name": "providers/evercrypt/EverCrypt.AutoConfig2.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 18,
"end_line": 24,
"start_col": 0,
"start_line": 20
} | (** This module, unlike the previous attempt at autoconfig, is entirely written
in Low* + Vale, and does not play dirty tricks with global variables. As such,
there is no C implementation for it, only an .fst file.
This module revolves around individual feature flags, which can be selectively
disabled. *)
module EverCrypt.AutoConfig2
open FStar.HyperStack.ST
open EverCrypt.TargetConfig
module B = LowStar.Buffer
(** Each flag can be queried; we cache the results in mutable global variables,
hidden behind an abstract footprint. Calling a getter requires no reasoning
about the abstract footprint from the client. *)
unfold | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.AutoConfig2.fsti"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt.TargetConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | flag: Prims.bool -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.b2t",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.l_imp"
] | [] | false | false | false | true | true | let getter (flag: bool) =
| unit
-> Stack bool
(requires (fun _ -> true))
(ensures (fun h0 b h1 -> B.(modifies loc_none h0 h1) /\ (b ==> flag))) | false |
|
EverCrypt.AutoConfig2.fsti | EverCrypt.AutoConfig2.vec128_enabled | val vec128_enabled : Prims.bool | let vec128_enabled = Vale.X64.CPU_Features_s.avx_enabled || vec128_not_avx_enabled | {
"file_name": "providers/evercrypt/EverCrypt.AutoConfig2.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 82,
"end_line": 98,
"start_col": 0,
"start_line": 98
} | (** This module, unlike the previous attempt at autoconfig, is entirely written
in Low* + Vale, and does not play dirty tricks with global variables. As such,
there is no C implementation for it, only an .fst file.
This module revolves around individual feature flags, which can be selectively
disabled. *)
module EverCrypt.AutoConfig2
open FStar.HyperStack.ST
open EverCrypt.TargetConfig
module B = LowStar.Buffer
(** Each flag can be queried; we cache the results in mutable global variables,
hidden behind an abstract footprint. Calling a getter requires no reasoning
about the abstract footprint from the client. *)
unfold
inline_for_extraction noextract
let getter (flag: bool) = unit -> Stack bool
(requires (fun _ -> true))
(ensures (fun h0 b h1 ->
B.(modifies loc_none h0 h1) /\
(b ==> flag)))
val has_shaext: getter Vale.X64.CPU_Features_s.sha_enabled
val has_aesni: getter Vale.X64.CPU_Features_s.aesni_enabled
val has_pclmulqdq: getter Vale.X64.CPU_Features_s.pclmulqdq_enabled
val has_avx2: getter Vale.X64.CPU_Features_s.avx2_enabled
val has_avx: getter Vale.X64.CPU_Features_s.avx_enabled
val has_bmi2: getter Vale.X64.CPU_Features_s.bmi2_enabled
val has_adx: getter Vale.X64.CPU_Features_s.adx_enabled
val has_sse: getter Vale.X64.CPU_Features_s.sse_enabled
val has_movbe: getter Vale.X64.CPU_Features_s.movbe_enabled
val has_rdrand: getter Vale.X64.CPU_Features_s.rdrand_enabled
(** At the moment, has_avx512 contains the AVX512_F, AVX512_DQ, AVX512_BW and AVX512_VL flags
See Vale.X64.CPU_Features_s for more details. **)
val has_avx512: getter Vale.X64.CPU_Features_s.avx512_enabled
(** A set of functions that modify the global cached results. For this, the
client needs to reason about the abstract footprint. *)
val fp: unit -> GTot B.loc
(* A client that needs to allocate first then call init should use recall before
anything else; this way, the client will be able to derive disjointness of their
allocations and of fp. *)
val recall: unit -> Stack unit
(requires (fun _ -> True))
(ensures (fun h0 _ h1 ->
B.(loc_not_unused_in h1 `loc_includes` (fp ())) /\ h0 == h1))
(* By default, all feature flags are disabled. A client must call init to get
meaningful results from the various has_* functions. *)
val init: unit -> Stack unit
(requires (fun _ -> True))
(ensures (fun h0 _ h1 ->
B.modifies (fp ()) h0 h1))
inline_for_extraction
let disabler = unit -> Stack unit
(requires (fun _ -> true))
(ensures (fun h0 _ h1 -> B.(modifies (fp ()) h0 h1)))
(* In order to selectively take codepaths, a client might disable either feature
flags, to, say, pick one Vale implementation over another. Alternatively, if the
codepath taken does not depend on a particular feature flag (e.g. OpenSSL vs.
BCrypt) the client can disable a provider entirely. *)
val disable_avx2: disabler
val disable_avx: disabler
val disable_bmi2: disabler
val disable_adx: disabler
val disable_shaext: disabler
val disable_aesni: disabler
val disable_pclmulqdq: disabler
val disable_sse: disabler
val disable_movbe: disabler
val disable_rdrand: disabler
val disable_avx512: disabler
(** Some predicates to dynamically guard the vectorized code *)
(* Note that those predicates don't check [EverCrypt.TargetConfig.hacl_can_compile_vec128],
* [EverCrypt.TargetConfig.hacl_can_compile_vale], etc.
* The reason is that the above booleans are static preconditions, checked at
* compilation time. The F* code must thus be guard the following way (note that
* the order of the arguments is important for syntactic reasons):
* [> if EverCrypt.TargetConfig.hacl_can_compile_vec128 && has_vec128 ... then
* Leading to the following C code:
* [> #if defined(COMPILE_128)
* [> if has_vec128 ... { ... }
* [> #endif
* Note that if one forgets to guard the code with flags like
* [EverCrypt.TargetConfig.hacl_can_compile_vec128], the code will not compile on platforms
* not satisfying the requirements.
*) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.AutoConfig2.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt.TargetConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.op_BarBar",
"Vale.X64.CPU_Features_s.avx_enabled",
"EverCrypt.TargetConfig.vec128_not_avx_enabled"
] | [] | false | false | false | true | false | let vec128_enabled =
| Vale.X64.CPU_Features_s.avx_enabled || vec128_not_avx_enabled | false |
|
EverCrypt.AutoConfig2.fsti | EverCrypt.AutoConfig2.vec256_enabled | val vec256_enabled : Prims.bool | let vec256_enabled = Vale.X64.CPU_Features_s.avx2_enabled || vec256_not_avx2_enabled | {
"file_name": "providers/evercrypt/EverCrypt.AutoConfig2.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 84,
"end_line": 100,
"start_col": 0,
"start_line": 100
} | (** This module, unlike the previous attempt at autoconfig, is entirely written
in Low* + Vale, and does not play dirty tricks with global variables. As such,
there is no C implementation for it, only an .fst file.
This module revolves around individual feature flags, which can be selectively
disabled. *)
module EverCrypt.AutoConfig2
open FStar.HyperStack.ST
open EverCrypt.TargetConfig
module B = LowStar.Buffer
(** Each flag can be queried; we cache the results in mutable global variables,
hidden behind an abstract footprint. Calling a getter requires no reasoning
about the abstract footprint from the client. *)
unfold
inline_for_extraction noextract
let getter (flag: bool) = unit -> Stack bool
(requires (fun _ -> true))
(ensures (fun h0 b h1 ->
B.(modifies loc_none h0 h1) /\
(b ==> flag)))
val has_shaext: getter Vale.X64.CPU_Features_s.sha_enabled
val has_aesni: getter Vale.X64.CPU_Features_s.aesni_enabled
val has_pclmulqdq: getter Vale.X64.CPU_Features_s.pclmulqdq_enabled
val has_avx2: getter Vale.X64.CPU_Features_s.avx2_enabled
val has_avx: getter Vale.X64.CPU_Features_s.avx_enabled
val has_bmi2: getter Vale.X64.CPU_Features_s.bmi2_enabled
val has_adx: getter Vale.X64.CPU_Features_s.adx_enabled
val has_sse: getter Vale.X64.CPU_Features_s.sse_enabled
val has_movbe: getter Vale.X64.CPU_Features_s.movbe_enabled
val has_rdrand: getter Vale.X64.CPU_Features_s.rdrand_enabled
(** At the moment, has_avx512 contains the AVX512_F, AVX512_DQ, AVX512_BW and AVX512_VL flags
See Vale.X64.CPU_Features_s for more details. **)
val has_avx512: getter Vale.X64.CPU_Features_s.avx512_enabled
(** A set of functions that modify the global cached results. For this, the
client needs to reason about the abstract footprint. *)
val fp: unit -> GTot B.loc
(* A client that needs to allocate first then call init should use recall before
anything else; this way, the client will be able to derive disjointness of their
allocations and of fp. *)
val recall: unit -> Stack unit
(requires (fun _ -> True))
(ensures (fun h0 _ h1 ->
B.(loc_not_unused_in h1 `loc_includes` (fp ())) /\ h0 == h1))
(* By default, all feature flags are disabled. A client must call init to get
meaningful results from the various has_* functions. *)
val init: unit -> Stack unit
(requires (fun _ -> True))
(ensures (fun h0 _ h1 ->
B.modifies (fp ()) h0 h1))
inline_for_extraction
let disabler = unit -> Stack unit
(requires (fun _ -> true))
(ensures (fun h0 _ h1 -> B.(modifies (fp ()) h0 h1)))
(* In order to selectively take codepaths, a client might disable either feature
flags, to, say, pick one Vale implementation over another. Alternatively, if the
codepath taken does not depend on a particular feature flag (e.g. OpenSSL vs.
BCrypt) the client can disable a provider entirely. *)
val disable_avx2: disabler
val disable_avx: disabler
val disable_bmi2: disabler
val disable_adx: disabler
val disable_shaext: disabler
val disable_aesni: disabler
val disable_pclmulqdq: disabler
val disable_sse: disabler
val disable_movbe: disabler
val disable_rdrand: disabler
val disable_avx512: disabler
(** Some predicates to dynamically guard the vectorized code *)
(* Note that those predicates don't check [EverCrypt.TargetConfig.hacl_can_compile_vec128],
* [EverCrypt.TargetConfig.hacl_can_compile_vale], etc.
* The reason is that the above booleans are static preconditions, checked at
* compilation time. The F* code must thus be guard the following way (note that
* the order of the arguments is important for syntactic reasons):
* [> if EverCrypt.TargetConfig.hacl_can_compile_vec128 && has_vec128 ... then
* Leading to the following C code:
* [> #if defined(COMPILE_128)
* [> if has_vec128 ... { ... }
* [> #endif
* Note that if one forgets to guard the code with flags like
* [EverCrypt.TargetConfig.hacl_can_compile_vec128], the code will not compile on platforms
* not satisfying the requirements.
*)
noextract
let vec128_enabled = Vale.X64.CPU_Features_s.avx_enabled || vec128_not_avx_enabled | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.AutoConfig2.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt.TargetConfig",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.op_BarBar",
"Vale.X64.CPU_Features_s.avx2_enabled",
"EverCrypt.TargetConfig.vec256_not_avx2_enabled"
] | [] | false | false | false | true | false | let vec256_enabled =
| Vale.X64.CPU_Features_s.avx2_enabled || vec256_not_avx2_enabled | false |
|
Hacl.HPKE.Interface.AEAD.fsti | Hacl.HPKE.Interface.AEAD.aead_encrypt_st | val aead_encrypt_st : a: Spec.Agile.HPKE.aead -> Type0 | let aead_encrypt_st (a:S.aead) =
_:squash (S.Seal? a /\ S.is_valid_aead a)
-> key:kv (S.Seal?.alg a)
-> nonce:iv (S.Seal?.alg a)
-> alen:size_t{v alen <= AEAD.max_length (S.Seal?.alg a)}
-> aad:lbuffer uint8 alen
-> len:size_t{v len + 16 <= max_size_t}
-> input:lbuffer uint8 len
-> output:lbuffer uint8 (size (v len + 16)) ->
Stack unit
(requires fun h ->
live h key /\ live h nonce /\ live h aad /\
live h input /\ live h output /\
disjoint key output /\ disjoint nonce output /\
eq_or_disjoint input output /\ disjoint aad output)
(ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\
(as_seq h1 output) `Seq.equal`
AEAD.encrypt #(S.Seal?.alg a) (as_seq h0 key) (as_seq h0 nonce) (as_seq h0 aad) (as_seq h0 input)) | {
"file_name": "code/hpke/Hacl.HPKE.Interface.AEAD.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 102,
"end_line": 37,
"start_col": 0,
"start_line": 20
} | module Hacl.HPKE.Interface.AEAD
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
module S = Spec.Agile.HPKE
module AEAD = Spec.Agile.AEAD
inline_for_extraction noextract
let kv (a:AEAD.alg) = lbuffer uint8 (size (AEAD.key_length a))
inline_for_extraction noextract
let iv (a:AEAD.alg) = lbuffer uint8 12ul
inline_for_extraction noextract
let tag (a:AEAD.alg) = lbuffer uint8 (size (AEAD.tag_length a)) | {
"checked_file": "/",
"dependencies": [
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.Interface.AEAD.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.HPKE.aead -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.aead",
"Prims.squash",
"Prims.l_and",
"Prims.b2t",
"Spec.Agile.HPKE.uu___is_Seal",
"Spec.Agile.HPKE.is_valid_aead",
"Hacl.HPKE.Interface.AEAD.kv",
"Spec.Agile.HPKE.__proj__Seal__item__alg",
"Hacl.HPKE.Interface.AEAD.iv",
"Lib.IntTypes.size_t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.Agile.AEAD.max_length",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.op_Addition",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.size",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"FStar.Seq.Base.equal",
"Lib.Buffer.as_seq",
"Spec.Agile.AEAD.encrypt",
"Spec.Agile.AEAD.key_length",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | true | let aead_encrypt_st (a: S.aead) =
|
_: squash (S.Seal? a /\ S.is_valid_aead a) ->
key: kv (S.Seal?.alg a) ->
nonce: iv (S.Seal?.alg a) ->
alen: size_t{v alen <= AEAD.max_length (S.Seal?.alg a)} ->
aad: lbuffer uint8 alen ->
len: size_t{v len + 16 <= max_size_t} ->
input: lbuffer uint8 len ->
output: lbuffer uint8 (size (v len + 16))
-> Stack unit
(requires
fun h ->
live h key /\ live h nonce /\ live h aad /\ live h input /\ live h output /\
disjoint key output /\ disjoint nonce output /\ eq_or_disjoint input output /\
disjoint aad output)
(ensures
fun h0 _ h1 ->
modifies (loc output) h0 h1 /\
(as_seq h1 output)
`Seq.equal`
(AEAD.encrypt #(S.Seal?.alg a)
(as_seq h0 key)
(as_seq h0 nonce)
(as_seq h0 aad)
(as_seq h0 input))) | false |
|
Hacl.HPKE.Interface.AEAD.fsti | Hacl.HPKE.Interface.AEAD.aead_decrypt_st | val aead_decrypt_st : a: Spec.Agile.HPKE.aead -> Type0 | let aead_decrypt_st (a:S.aead) =
_:squash (S.Seal? a /\ S.is_valid_aead a)
-> key:kv (S.Seal?.alg a)
-> nonce:iv (S.Seal?.alg a)
-> alen:size_t{v alen <= AEAD.max_length (S.Seal?.alg a)}
-> aad:lbuffer uint8 alen
-> len:size_t{v len <= AEAD.max_length (S.Seal?.alg a) /\ v len + 16 <= max_size_t}
-> input:lbuffer uint8 len
-> output:lbuffer uint8 (size (v len + 16)) ->
Stack UInt32.t
(requires fun h ->
live h key /\ live h nonce /\ live h aad /\
live h input /\ live h output /\
eq_or_disjoint input output)
(ensures fun h0 z h1 -> modifies1 input h0 h1 /\
(let plain = AEAD.decrypt #(S.Seal?.alg a) (as_seq h0 key) (as_seq h0 nonce) (as_seq h0 aad) (as_seq h0 output) in
match z with
| 0ul -> Some? plain /\ as_seq h1 input `Seq.equal` Some?.v plain // decryption succeeded
| 1ul -> None? plain
| _ -> false) // decryption failed
) | {
"file_name": "code/hpke/Hacl.HPKE.Interface.AEAD.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 60,
"start_col": 0,
"start_line": 40
} | module Hacl.HPKE.Interface.AEAD
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
module S = Spec.Agile.HPKE
module AEAD = Spec.Agile.AEAD
inline_for_extraction noextract
let kv (a:AEAD.alg) = lbuffer uint8 (size (AEAD.key_length a))
inline_for_extraction noextract
let iv (a:AEAD.alg) = lbuffer uint8 12ul
inline_for_extraction noextract
let tag (a:AEAD.alg) = lbuffer uint8 (size (AEAD.tag_length a))
inline_for_extraction noextract
let aead_encrypt_st (a:S.aead) =
_:squash (S.Seal? a /\ S.is_valid_aead a)
-> key:kv (S.Seal?.alg a)
-> nonce:iv (S.Seal?.alg a)
-> alen:size_t{v alen <= AEAD.max_length (S.Seal?.alg a)}
-> aad:lbuffer uint8 alen
-> len:size_t{v len + 16 <= max_size_t}
-> input:lbuffer uint8 len
-> output:lbuffer uint8 (size (v len + 16)) ->
Stack unit
(requires fun h ->
live h key /\ live h nonce /\ live h aad /\
live h input /\ live h output /\
disjoint key output /\ disjoint nonce output /\
eq_or_disjoint input output /\ disjoint aad output)
(ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\
(as_seq h1 output) `Seq.equal`
AEAD.encrypt #(S.Seal?.alg a) (as_seq h0 key) (as_seq h0 nonce) (as_seq h0 aad) (as_seq h0 input)) | {
"checked_file": "/",
"dependencies": [
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.Interface.AEAD.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.HPKE.aead -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.aead",
"Prims.squash",
"Prims.l_and",
"Prims.b2t",
"Spec.Agile.HPKE.uu___is_Seal",
"Spec.Agile.HPKE.is_valid_aead",
"Hacl.HPKE.Interface.AEAD.kv",
"Spec.Agile.HPKE.__proj__Seal__item__alg",
"Hacl.HPKE.Interface.AEAD.iv",
"Lib.IntTypes.size_t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.Agile.AEAD.max_length",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.op_Addition",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.size",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies1",
"FStar.Pervasives.Native.uu___is_Some",
"Spec.Agile.AEAD.decrypted",
"Lib.Buffer.as_seq",
"FStar.Seq.Base.equal",
"FStar.Pervasives.Native.__proj__Some__item__v",
"FStar.Pervasives.Native.uu___is_None",
"Prims.logical",
"FStar.Pervasives.Native.option",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mk_int",
"Spec.Agile.AEAD.decrypt",
"Spec.Agile.AEAD.key_length",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | true | let aead_decrypt_st (a: S.aead) =
|
_: squash (S.Seal? a /\ S.is_valid_aead a) ->
key: kv (S.Seal?.alg a) ->
nonce: iv (S.Seal?.alg a) ->
alen: size_t{v alen <= AEAD.max_length (S.Seal?.alg a)} ->
aad: lbuffer uint8 alen ->
len: size_t{v len <= AEAD.max_length (S.Seal?.alg a) /\ v len + 16 <= max_size_t} ->
input: lbuffer uint8 len ->
output: lbuffer uint8 (size (v len + 16))
-> Stack UInt32.t
(requires
fun h ->
live h key /\ live h nonce /\ live h aad /\ live h input /\ live h output /\
eq_or_disjoint input output)
(ensures
fun h0 z h1 ->
modifies1 input h0 h1 /\
(let plain =
AEAD.decrypt #(S.Seal?.alg a)
(as_seq h0 key)
(as_seq h0 nonce)
(as_seq h0 aad)
(as_seq h0 output)
in
match z with
| 0ul -> Some? plain /\ (as_seq h1 input) `Seq.equal` (Some?.v plain)
| 1ul -> None? plain
| _ -> false)) | false |
|
Vale.Transformers.BoundedInstructionEffects.fsti | Vale.Transformers.BoundedInstructionEffects.safely_bounded | val safely_bounded : i: Vale.X64.Machine_Semantics_s.ins -> Prims.bool | let safely_bounded (i:ins) =
Instr? i | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 10,
"end_line": 100,
"start_col": 0,
"start_line": 99
} | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Machine_s
open Vale.X64.Machine_Semantics_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
module L = FStar.List.Tot
(** A [location_with_value] contains a location and the value it must hold *)
type location_with_value = l:location_eq & location_val_eqt l
(** A [locations_with_values] contains locations and values they must hold *)
type locations_with_values = list location_with_value
(** An [rw_set] contains information about what locations are read and
written by a stateful operation. *)
type rw_set = {
loc_reads: locations;
loc_writes: locations;
loc_constant_writes: locations_with_values;
}
(** [rw_set_of_ins i] returns the read/write sets for the execution of
an instruction. *)
val rw_set_of_ins : i:ins -> rw_set
(** [locations_of_ocmp o] returns the read set for a comparison operator. *)
val locations_of_ocmp : o:ocmp -> locations
(** [unchanged_except exc s1 s2] means all locations that are disjoint
from the exceptions [exc] have the same value in both [s1] and [s2]. *)
let unchanged_except (exceptions:locations) (s1 s2:machine_state) :
GTot Type0 =
(forall (a:location). {:pattern (eval_location a s2)} (
(!!(disjoint_location_from_locations a exceptions) ==>
(eval_location a s1 == eval_location a s2))
))
(** [only_affects locs f] means that running [f] leaves everything
except [locs] unchanged. *)
let only_affects (locs:locations) (f:st unit) : GTot Type0 =
forall s. {:pattern unchanged_except locs s (run f s)} (
(run f s).ms_ok ==> unchanged_except locs s (run f s)
)
(** [unchanged_at locs s1 s2] means the the value of any location in
[locs] is same in both [s1] and [s2]. *)
let rec unchanged_at (locs:locations) (s1 s2:machine_state) : GTot Type0 =
match locs with
| [] -> True
| x :: xs -> (
(eval_location x s1 == eval_location x s2) /\
(unchanged_at xs s1 s2)
)
(** [constant_on_execution locv f s] means that running [f] on [s]
ensures that the values of the locations in [locv] always match
the values given to them in [locv]. *)
let rec constant_on_execution (locv:locations_with_values) (f:st unit) (s:machine_state) : GTot Type0 =
(run f s).ms_ok ==> (
match locv with
| [] -> True
| (|l, v|) :: xs -> (
(eval_location l (run f s) == raise_location_val_eqt v) /\
(constant_on_execution xs f s)
)
)
(** [bounded_effects rw f] means that the execution of [f] is bounded
by the read-write [rw]. This means that whenever two different
states are same at the locations in [rw.loc_reads], then the
function will have the same effect, and that its effect is bounded
to the set [rw.loc_writes]. Additionally, execution always causes
the resultant state to cause the results to be written as per
[rw.loc_constant_writes]. *)
let bounded_effects (rw:rw_set) (f:st unit) : GTot Type0 =
(only_affects rw.loc_writes f) /\
(forall s. {:pattern (constant_on_execution rw.loc_constant_writes f s)}
constant_on_execution rw.loc_constant_writes f s) /\
(forall l v. {:pattern (L.mem (|l,v|) rw.loc_constant_writes); (L.mem l rw.loc_writes)}
L.mem (|l,v|) rw.loc_constant_writes ==> L.mem l rw.loc_writes) /\
(
forall s1 s2. {:pattern (run f s1); (run f s2)} (
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2) ==> (
((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==>
unchanged_at rw.loc_writes (run f s1) (run f s2))
)
)
)
(** Safely bounded instructions are instructions that we can guarantee
[bounded_effects] upon their execution. For the rest of the
instructions, we currently don't have proofs about | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fsti.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: Vale.X64.Machine_Semantics_s.ins -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Bytes_Code_s.uu___is_Instr",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Prims.bool"
] | [] | false | false | false | true | false | let safely_bounded (i: ins) =
| Instr? i | false |
|
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.loc_all_regions_from | val loc_all_regions_from (preserve_liveness: bool) (r: HS.rid) : GTot loc | val loc_all_regions_from (preserve_liveness: bool) (r: HS.rid) : GTot loc | let loc_all_regions_from
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (HS.mod_set (Set.singleton r)) | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 62,
"end_line": 590,
"start_col": 0,
"start_line": 586
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul)
let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b
let length_null_2 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true)) (ensures (length b == 0))
[SMTPat (g_is_null b)]
= len_null a rrel rel;
null_unique b
/// For functional correctness, buffers are reflected at the proof
/// level using sequences, via ``as_seq b h``, which returns the
/// contents of a given buffer ``b`` in a given heap ``h``. If ``b`` is not
/// live in ``h``, then the result is unspecified.
(* TODO: why not return a lseq and remove length_as_seq lemma? *)
val as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot (Seq.seq a)
/// The contents of a buffer ``b`` has the same length as ``b`` itself.
val length_as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (Seq.length (as_seq h b) == length b)
[SMTPat (Seq.length (as_seq h b))]
/// ``get`` is an often-convenient shorthand to index the value of a
/// given buffer in a given heap, for proof purposes.
let get (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (p:mbuffer a rrel rel) (i:nat)
:Ghost a (requires (i < length p)) (ensures (fun _ -> True))
= Seq.index (as_seq h p) i
/// Injectivity in the first preorder
val mbuffer_injectivity_in_first_preorder (_:unit)
: Lemma (forall (a:Type0) (rrel1 rrel2 rel1 rel2:srel a)
(b1:mbuffer a rrel1 rel1)
(b2:mbuffer a rrel2 rel2).
rrel1 =!= rrel2 ==> ~ (b1 === b2))
/// Before defining sub-buffer related API, we need to define the notion of "compatibility"
///
///
/// Sub-buffers can be taken at a different preorder than their parent buffers
/// But we need to ensure that the changes to the sub-buffer are compatible with the preorder
/// of the parent buffer, and vice versa.
(*
* The quantifiers are fiercely guarded, so if you are working directly with them,
* you may have to write additional asserts as triggers
*)
[@@"opaque_to_smt"]
unfold let compatible_sub
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t{U32.v i + U32.v len <= length b}) (sub_rel:srel a)
= compatible_subseq_preorder (length b) rel (U32.v i) (U32.v i + U32.v len) sub_rel
/// ``gsub`` is the way to carve a sub-buffer out of a given
/// buffer. ``gsub b i len`` return the sub-buffer of ``b`` starting from
/// offset ``i`` within ``b``, and with length ``len``. Of course ``i`` and
/// ``len`` must fit within the length of ``b``.
///
/// Further the clients can attach a preorder with the subbuffer (sub_rel),
/// provided it is compatible
///
/// ``gsub`` is the ghost version, for proof purposes. Its stateful
/// counterpart is ``sub``, see below.
val mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Ghost (mbuffer a rrel sub_rel)
(requires (U32.v i + U32.v len <= length b))
(ensures (fun _ -> True))
// goffset
/// A buffer is live exactly at the same time as all of its sub-buffers.
val live_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b /\ compatible_sub b i len sub_rel))
(ensures (live h b <==> (live h (mgsub sub_rel b i len) /\ (exists h0 . {:pattern (live h0 b)} live h0 b))))
[SMTPatOr [
[SMTPat (live h (mgsub sub_rel b i len))];
[SMTPat (live h b); SMTPat (mgsub sub_rel b i len);]
]]
val gsub_is_null (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (g_is_null (mgsub sub_rel b i len) <==> g_is_null b))
[SMTPat (g_is_null (mgsub sub_rel b i len))]
/// The length of a sub-buffer is exactly the one provided at ``gsub``.
val len_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len':U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len' <= length b))
(ensures (len (mgsub sub_rel b i len') == len'))
[SMTPatOr [
[SMTPat (len (mgsub sub_rel b i len'))];
[SMTPat (length (mgsub sub_rel b i len'))];
]]
val frameOf_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (frameOf (mgsub sub_rel b i len) == frameOf b))
[SMTPat (frameOf (mgsub sub_rel b i len))]
val as_addr_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_addr (mgsub sub_rel b i len) == as_addr b))
[SMTPat (as_addr (mgsub sub_rel b i len))]
val mgsub_inj (#a:Type0) (#rrel #rel:srel a) (sub_rel1 sub_rel2:srel a)
(b1 b2:mbuffer a rrel rel)
(i1 i2:U32.t)
(len1 len2:U32.t)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b1 /\
U32.v i2 + U32.v len2 <= length b2 /\
mgsub sub_rel1 b1 i1 len1 === mgsub sub_rel2 b2 i2 len2))
(ensures (len1 == len2 /\ (b1 == b2 ==> i1 == i2) /\ ((i1 == i2 /\ length b1 == length b2) ==> b1 == b2)))
/// Nesting two ``gsub`` collapses into one ``gsub``, transitively.
val gsub_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i1:U32.t) (len1:U32.t) (sub_rel1:srel a)
(i2: U32.t) (len2: U32.t) (sub_rel2:srel a)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b /\
U32.v i2 + U32.v len2 <= U32.v len1))
(ensures (((compatible_sub b i1 len1 sub_rel1 /\ compatible_sub (mgsub sub_rel1 b i1 len1) i2 len2 sub_rel2) ==> compatible_sub b (U32.add i1 i2) len2 sub_rel2) /\
mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2 == mgsub sub_rel2 b (U32.add i1 i2) len2))
[SMTPat (mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2)]
/// A buffer ``b`` is equal to its "largest" sub-buffer, at index 0 and
/// length ``len b``.
val gsub_zero_length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (compatible_sub b 0ul (len b) rel /\ b == mgsub rel b 0ul (len b))
/// The contents of a sub-buffer is the corresponding slice of the
/// contents of its enclosing buffer.
val as_seq_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_seq h (mgsub sub_rel b i len) == Seq.slice (as_seq h b) (U32.v i) (U32.v i + U32.v len)))
[SMTPat (as_seq h (mgsub sub_rel b i len))]
/// Two live non-null buffers having the same region and address have
/// their elements of the same type.
val live_same_addresses_equal_types_and_preorders
(#a1 #a2: Type0)
(#rrel1 #rel1: srel a1)
(#rrel2 #rel2: srel a2)
(b1: mbuffer a1 rrel1 rel1)
(b2: mbuffer a2 rrel2 rel2)
(h: HS.mem)
: Lemma
((frameOf b1 == frameOf b2 /\ as_addr b1 == as_addr b2 /\ live h b1 /\ live h b2 /\ (~ (g_is_null b1 /\ g_is_null b2))) ==> (a1 == a2 /\ rrel1 == rrel2))
/// # The modifies clause
///
/// The modifies clause for regions, references and buffers.
/// ==========================================================
///
/// This module presents the modifies clause, a way to track the set
/// of memory locations modified by a stateful Low* (or even F*)
/// program. The basic principle of modifies clauses is that any
/// location that is disjoint from a set of memory locations modified
/// by an operation is preserved by that operation.
///
/// We start by specifying a monoid of sets of memory locations. From
/// a rough high-level view, ``loc`` is the type of sets of memory
/// locations, equipped with an identity element ``loc_none``,
/// representing the empty set, and an associative and commutative
/// operator, ``loc_union``, representing the union of two sets of
/// memory locations.
///
/// Moreover, ``loc_union`` is idempotent, which is useful to cut SMT
/// matching loops with ``modifies_trans`` and ``modifies_refl`` below.
val loc : Type0
val loc_none: loc
val loc_union
(s1 s2: loc)
: GTot loc
val loc_union_idem
(s: loc)
: Lemma
(loc_union s s == s)
[SMTPat (loc_union s s)]
val loc_union_comm
(s1 s2: loc)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
[SMTPat (loc_union s1 s2)]
val loc_union_assoc
(s1 s2 s3: loc)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
let loc_union_idem_1
(s1 s2: loc)
: Lemma
(loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))]
= loc_union_assoc s1 s1 s2
let loc_union_idem_2
(s1 s2: loc)
: Lemma
(loc_union (loc_union s1 s2) s2 == loc_union s1 s2)
[SMTPat (loc_union (loc_union s1 s2) s2)]
= loc_union_assoc s1 s2 s2
val loc_union_loc_none_l
(s: loc)
: Lemma
(loc_union loc_none s == s)
[SMTPat (loc_union loc_none s)]
val loc_union_loc_none_r
(s: loc)
: Lemma
(loc_union s loc_none == s)
[SMTPat (loc_union s loc_none)]
/// ``loc_buffer b`` is the set of memory locations associated to a buffer ``b``.
val loc_buffer_from_to (#a:Type0) (#rrel #rel:srel a) (b: mbuffer a rrel rel) (from to: U32.t) : GTot loc
val loc_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc
val loc_buffer_eq (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) : Lemma
(loc_buffer b == loc_buffer_from_to b 0ul (len b))
val loc_buffer_from_to_high (#a: Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (length b <= U32.v to))
(ensures (loc_buffer_from_to b from to == loc_buffer_from_to b from (len b)))
val loc_buffer_from_to_none (#a: Type) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (g_is_null b \/ length b < U32.v from \/ U32.v to < U32.v from))
(ensures (loc_buffer_from_to b from to == loc_none))
val loc_buffer_from_to_mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
(from to: U32.t)
: Lemma
(requires (
U32.v i + U32.v len <= length b /\
U32.v from <= U32.v to /\ U32.v to <= U32.v len
))
(ensures (
loc_buffer_from_to (mgsub sub_rel b i len) from to == loc_buffer_from_to b (i `U32.add` from) (i `U32.add` to)
))
val loc_buffer_mgsub_eq (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub sub_rel b i len) == loc_buffer_from_to b i (i `U32.add` len)))
val loc_buffer_null (a:Type0) (rrel rel:srel a)
:Lemma (loc_buffer (mnull #a #rrel #rel) == loc_none)
[SMTPat (loc_buffer (mnull #a #rrel #rel))]
val loc_buffer_from_to_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(from to: U32.t)
: Lemma
(requires (U32.v from <= U32.v to /\ U32.v to <= length b))
(ensures (loc_buffer_from_to b from to == loc_buffer (mgsub rel b from (to `U32.sub` from))))
[SMTPat (loc_buffer_from_to b from to)]
val loc_buffer_mgsub_rel_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(rel1 rel2: srel a)
(i len: U32.t)
: Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub rel1 b i len) == loc_buffer (mgsub rel2 b i len)))
[SMTPat (loc_buffer (mgsub rel1 b i len)); SMTPat (loc_buffer (mgsub rel2 b i len))]
/// ``loc_addresses r n`` is the set of memory locations associated to a
/// set of addresses ``n`` in a given region ``r``.
val loc_addresses
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot loc
unfold let loc_addr_of_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc =
loc_addresses false (frameOf b) (Set.singleton (as_addr b))
/// ``loc_regions r`` is the set of memory locations associated to a set
/// ``r`` of regions.
val loc_regions
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot loc
/// ``loc_mreference b`` is the set of memory locations associated to a
/// reference ``b``, which is actually the set of memory locations
/// associated to the address of ``b``.
unfold
let loc_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
unfold
let loc_freed_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
/// ``loc_region_only r`` is the set of memory locations associated to a
/// region ``r`` but not any region ``r'`` that extends ``r`` (in the sense
/// of ``FStar.HyperStack.extends``.)
unfold
let loc_region_only
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (Set.singleton r)
/// ``loc_all_regions_from r`` is the set of all memory locations
/// associated to a region ``r`` and any region ``r'`` that transitively
/// extends ``r`` (in the sense of ``FStar.HyperStack.extends``,
/// e.g. nested stack frames.) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.ModifiesGen",
"short_module": "MG"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | preserve_liveness: Prims.bool -> r: FStar.Monotonic.HyperHeap.rid
-> Prims.GTot LowStar.Monotonic.Buffer.loc | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.bool",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.loc_regions",
"FStar.Monotonic.HyperHeap.mod_set",
"FStar.Set.singleton",
"LowStar.Monotonic.Buffer.loc"
] | [] | false | false | false | false | false | let loc_all_regions_from (preserve_liveness: bool) (r: HS.rid) : GTot loc =
| loc_regions preserve_liveness (HS.mod_set (Set.singleton r)) | false |
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.loc_region_only | val loc_region_only (preserve_liveness: bool) (r: HS.rid) : GTot loc | val loc_region_only (preserve_liveness: bool) (r: HS.rid) : GTot loc | let loc_region_only
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (Set.singleton r) | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 577,
"start_col": 0,
"start_line": 573
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul)
let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b
let length_null_2 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true)) (ensures (length b == 0))
[SMTPat (g_is_null b)]
= len_null a rrel rel;
null_unique b
/// For functional correctness, buffers are reflected at the proof
/// level using sequences, via ``as_seq b h``, which returns the
/// contents of a given buffer ``b`` in a given heap ``h``. If ``b`` is not
/// live in ``h``, then the result is unspecified.
(* TODO: why not return a lseq and remove length_as_seq lemma? *)
val as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot (Seq.seq a)
/// The contents of a buffer ``b`` has the same length as ``b`` itself.
val length_as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (Seq.length (as_seq h b) == length b)
[SMTPat (Seq.length (as_seq h b))]
/// ``get`` is an often-convenient shorthand to index the value of a
/// given buffer in a given heap, for proof purposes.
let get (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (p:mbuffer a rrel rel) (i:nat)
:Ghost a (requires (i < length p)) (ensures (fun _ -> True))
= Seq.index (as_seq h p) i
/// Injectivity in the first preorder
val mbuffer_injectivity_in_first_preorder (_:unit)
: Lemma (forall (a:Type0) (rrel1 rrel2 rel1 rel2:srel a)
(b1:mbuffer a rrel1 rel1)
(b2:mbuffer a rrel2 rel2).
rrel1 =!= rrel2 ==> ~ (b1 === b2))
/// Before defining sub-buffer related API, we need to define the notion of "compatibility"
///
///
/// Sub-buffers can be taken at a different preorder than their parent buffers
/// But we need to ensure that the changes to the sub-buffer are compatible with the preorder
/// of the parent buffer, and vice versa.
(*
* The quantifiers are fiercely guarded, so if you are working directly with them,
* you may have to write additional asserts as triggers
*)
[@@"opaque_to_smt"]
unfold let compatible_sub
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t{U32.v i + U32.v len <= length b}) (sub_rel:srel a)
= compatible_subseq_preorder (length b) rel (U32.v i) (U32.v i + U32.v len) sub_rel
/// ``gsub`` is the way to carve a sub-buffer out of a given
/// buffer. ``gsub b i len`` return the sub-buffer of ``b`` starting from
/// offset ``i`` within ``b``, and with length ``len``. Of course ``i`` and
/// ``len`` must fit within the length of ``b``.
///
/// Further the clients can attach a preorder with the subbuffer (sub_rel),
/// provided it is compatible
///
/// ``gsub`` is the ghost version, for proof purposes. Its stateful
/// counterpart is ``sub``, see below.
val mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Ghost (mbuffer a rrel sub_rel)
(requires (U32.v i + U32.v len <= length b))
(ensures (fun _ -> True))
// goffset
/// A buffer is live exactly at the same time as all of its sub-buffers.
val live_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b /\ compatible_sub b i len sub_rel))
(ensures (live h b <==> (live h (mgsub sub_rel b i len) /\ (exists h0 . {:pattern (live h0 b)} live h0 b))))
[SMTPatOr [
[SMTPat (live h (mgsub sub_rel b i len))];
[SMTPat (live h b); SMTPat (mgsub sub_rel b i len);]
]]
val gsub_is_null (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (g_is_null (mgsub sub_rel b i len) <==> g_is_null b))
[SMTPat (g_is_null (mgsub sub_rel b i len))]
/// The length of a sub-buffer is exactly the one provided at ``gsub``.
val len_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len':U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len' <= length b))
(ensures (len (mgsub sub_rel b i len') == len'))
[SMTPatOr [
[SMTPat (len (mgsub sub_rel b i len'))];
[SMTPat (length (mgsub sub_rel b i len'))];
]]
val frameOf_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (frameOf (mgsub sub_rel b i len) == frameOf b))
[SMTPat (frameOf (mgsub sub_rel b i len))]
val as_addr_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_addr (mgsub sub_rel b i len) == as_addr b))
[SMTPat (as_addr (mgsub sub_rel b i len))]
val mgsub_inj (#a:Type0) (#rrel #rel:srel a) (sub_rel1 sub_rel2:srel a)
(b1 b2:mbuffer a rrel rel)
(i1 i2:U32.t)
(len1 len2:U32.t)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b1 /\
U32.v i2 + U32.v len2 <= length b2 /\
mgsub sub_rel1 b1 i1 len1 === mgsub sub_rel2 b2 i2 len2))
(ensures (len1 == len2 /\ (b1 == b2 ==> i1 == i2) /\ ((i1 == i2 /\ length b1 == length b2) ==> b1 == b2)))
/// Nesting two ``gsub`` collapses into one ``gsub``, transitively.
val gsub_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i1:U32.t) (len1:U32.t) (sub_rel1:srel a)
(i2: U32.t) (len2: U32.t) (sub_rel2:srel a)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b /\
U32.v i2 + U32.v len2 <= U32.v len1))
(ensures (((compatible_sub b i1 len1 sub_rel1 /\ compatible_sub (mgsub sub_rel1 b i1 len1) i2 len2 sub_rel2) ==> compatible_sub b (U32.add i1 i2) len2 sub_rel2) /\
mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2 == mgsub sub_rel2 b (U32.add i1 i2) len2))
[SMTPat (mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2)]
/// A buffer ``b`` is equal to its "largest" sub-buffer, at index 0 and
/// length ``len b``.
val gsub_zero_length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (compatible_sub b 0ul (len b) rel /\ b == mgsub rel b 0ul (len b))
/// The contents of a sub-buffer is the corresponding slice of the
/// contents of its enclosing buffer.
val as_seq_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_seq h (mgsub sub_rel b i len) == Seq.slice (as_seq h b) (U32.v i) (U32.v i + U32.v len)))
[SMTPat (as_seq h (mgsub sub_rel b i len))]
/// Two live non-null buffers having the same region and address have
/// their elements of the same type.
val live_same_addresses_equal_types_and_preorders
(#a1 #a2: Type0)
(#rrel1 #rel1: srel a1)
(#rrel2 #rel2: srel a2)
(b1: mbuffer a1 rrel1 rel1)
(b2: mbuffer a2 rrel2 rel2)
(h: HS.mem)
: Lemma
((frameOf b1 == frameOf b2 /\ as_addr b1 == as_addr b2 /\ live h b1 /\ live h b2 /\ (~ (g_is_null b1 /\ g_is_null b2))) ==> (a1 == a2 /\ rrel1 == rrel2))
/// # The modifies clause
///
/// The modifies clause for regions, references and buffers.
/// ==========================================================
///
/// This module presents the modifies clause, a way to track the set
/// of memory locations modified by a stateful Low* (or even F*)
/// program. The basic principle of modifies clauses is that any
/// location that is disjoint from a set of memory locations modified
/// by an operation is preserved by that operation.
///
/// We start by specifying a monoid of sets of memory locations. From
/// a rough high-level view, ``loc`` is the type of sets of memory
/// locations, equipped with an identity element ``loc_none``,
/// representing the empty set, and an associative and commutative
/// operator, ``loc_union``, representing the union of two sets of
/// memory locations.
///
/// Moreover, ``loc_union`` is idempotent, which is useful to cut SMT
/// matching loops with ``modifies_trans`` and ``modifies_refl`` below.
val loc : Type0
val loc_none: loc
val loc_union
(s1 s2: loc)
: GTot loc
val loc_union_idem
(s: loc)
: Lemma
(loc_union s s == s)
[SMTPat (loc_union s s)]
val loc_union_comm
(s1 s2: loc)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
[SMTPat (loc_union s1 s2)]
val loc_union_assoc
(s1 s2 s3: loc)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
let loc_union_idem_1
(s1 s2: loc)
: Lemma
(loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))]
= loc_union_assoc s1 s1 s2
let loc_union_idem_2
(s1 s2: loc)
: Lemma
(loc_union (loc_union s1 s2) s2 == loc_union s1 s2)
[SMTPat (loc_union (loc_union s1 s2) s2)]
= loc_union_assoc s1 s2 s2
val loc_union_loc_none_l
(s: loc)
: Lemma
(loc_union loc_none s == s)
[SMTPat (loc_union loc_none s)]
val loc_union_loc_none_r
(s: loc)
: Lemma
(loc_union s loc_none == s)
[SMTPat (loc_union s loc_none)]
/// ``loc_buffer b`` is the set of memory locations associated to a buffer ``b``.
val loc_buffer_from_to (#a:Type0) (#rrel #rel:srel a) (b: mbuffer a rrel rel) (from to: U32.t) : GTot loc
val loc_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc
val loc_buffer_eq (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) : Lemma
(loc_buffer b == loc_buffer_from_to b 0ul (len b))
val loc_buffer_from_to_high (#a: Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (length b <= U32.v to))
(ensures (loc_buffer_from_to b from to == loc_buffer_from_to b from (len b)))
val loc_buffer_from_to_none (#a: Type) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (g_is_null b \/ length b < U32.v from \/ U32.v to < U32.v from))
(ensures (loc_buffer_from_to b from to == loc_none))
val loc_buffer_from_to_mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
(from to: U32.t)
: Lemma
(requires (
U32.v i + U32.v len <= length b /\
U32.v from <= U32.v to /\ U32.v to <= U32.v len
))
(ensures (
loc_buffer_from_to (mgsub sub_rel b i len) from to == loc_buffer_from_to b (i `U32.add` from) (i `U32.add` to)
))
val loc_buffer_mgsub_eq (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub sub_rel b i len) == loc_buffer_from_to b i (i `U32.add` len)))
val loc_buffer_null (a:Type0) (rrel rel:srel a)
:Lemma (loc_buffer (mnull #a #rrel #rel) == loc_none)
[SMTPat (loc_buffer (mnull #a #rrel #rel))]
val loc_buffer_from_to_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(from to: U32.t)
: Lemma
(requires (U32.v from <= U32.v to /\ U32.v to <= length b))
(ensures (loc_buffer_from_to b from to == loc_buffer (mgsub rel b from (to `U32.sub` from))))
[SMTPat (loc_buffer_from_to b from to)]
val loc_buffer_mgsub_rel_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(rel1 rel2: srel a)
(i len: U32.t)
: Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub rel1 b i len) == loc_buffer (mgsub rel2 b i len)))
[SMTPat (loc_buffer (mgsub rel1 b i len)); SMTPat (loc_buffer (mgsub rel2 b i len))]
/// ``loc_addresses r n`` is the set of memory locations associated to a
/// set of addresses ``n`` in a given region ``r``.
val loc_addresses
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot loc
unfold let loc_addr_of_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc =
loc_addresses false (frameOf b) (Set.singleton (as_addr b))
/// ``loc_regions r`` is the set of memory locations associated to a set
/// ``r`` of regions.
val loc_regions
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot loc
/// ``loc_mreference b`` is the set of memory locations associated to a
/// reference ``b``, which is actually the set of memory locations
/// associated to the address of ``b``.
unfold
let loc_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
unfold
let loc_freed_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
/// ``loc_region_only r`` is the set of memory locations associated to a
/// region ``r`` but not any region ``r'`` that extends ``r`` (in the sense
/// of ``FStar.HyperStack.extends``.) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.ModifiesGen",
"short_module": "MG"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | preserve_liveness: Prims.bool -> r: FStar.Monotonic.HyperHeap.rid
-> Prims.GTot LowStar.Monotonic.Buffer.loc | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.bool",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.loc_regions",
"FStar.Set.singleton",
"LowStar.Monotonic.Buffer.loc"
] | [] | false | false | false | false | false | let loc_region_only (preserve_liveness: bool) (r: HS.rid) : GTot loc =
| loc_regions preserve_liveness (Set.singleton r) | false |
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.loc_includes_union_l' | val loc_includes_union_l' (s1 s2 s: loc)
: Lemma (requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
[SMTPat (loc_includes (loc_union s1 s2) s)] | val loc_includes_union_l' (s1 s2 s: loc)
: Lemma (requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
[SMTPat (loc_includes (loc_union s1 s2) s)] | let loc_includes_union_l'
(s1 s2 s: loc)
: Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
[SMTPat (loc_includes (loc_union s1 s2) s)]
= loc_includes_union_l s1 s2 s | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 643,
"start_col": 0,
"start_line": 637
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul)
let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b
let length_null_2 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true)) (ensures (length b == 0))
[SMTPat (g_is_null b)]
= len_null a rrel rel;
null_unique b
/// For functional correctness, buffers are reflected at the proof
/// level using sequences, via ``as_seq b h``, which returns the
/// contents of a given buffer ``b`` in a given heap ``h``. If ``b`` is not
/// live in ``h``, then the result is unspecified.
(* TODO: why not return a lseq and remove length_as_seq lemma? *)
val as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot (Seq.seq a)
/// The contents of a buffer ``b`` has the same length as ``b`` itself.
val length_as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (Seq.length (as_seq h b) == length b)
[SMTPat (Seq.length (as_seq h b))]
/// ``get`` is an often-convenient shorthand to index the value of a
/// given buffer in a given heap, for proof purposes.
let get (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (p:mbuffer a rrel rel) (i:nat)
:Ghost a (requires (i < length p)) (ensures (fun _ -> True))
= Seq.index (as_seq h p) i
/// Injectivity in the first preorder
val mbuffer_injectivity_in_first_preorder (_:unit)
: Lemma (forall (a:Type0) (rrel1 rrel2 rel1 rel2:srel a)
(b1:mbuffer a rrel1 rel1)
(b2:mbuffer a rrel2 rel2).
rrel1 =!= rrel2 ==> ~ (b1 === b2))
/// Before defining sub-buffer related API, we need to define the notion of "compatibility"
///
///
/// Sub-buffers can be taken at a different preorder than their parent buffers
/// But we need to ensure that the changes to the sub-buffer are compatible with the preorder
/// of the parent buffer, and vice versa.
(*
* The quantifiers are fiercely guarded, so if you are working directly with them,
* you may have to write additional asserts as triggers
*)
[@@"opaque_to_smt"]
unfold let compatible_sub
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t{U32.v i + U32.v len <= length b}) (sub_rel:srel a)
= compatible_subseq_preorder (length b) rel (U32.v i) (U32.v i + U32.v len) sub_rel
/// ``gsub`` is the way to carve a sub-buffer out of a given
/// buffer. ``gsub b i len`` return the sub-buffer of ``b`` starting from
/// offset ``i`` within ``b``, and with length ``len``. Of course ``i`` and
/// ``len`` must fit within the length of ``b``.
///
/// Further the clients can attach a preorder with the subbuffer (sub_rel),
/// provided it is compatible
///
/// ``gsub`` is the ghost version, for proof purposes. Its stateful
/// counterpart is ``sub``, see below.
val mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Ghost (mbuffer a rrel sub_rel)
(requires (U32.v i + U32.v len <= length b))
(ensures (fun _ -> True))
// goffset
/// A buffer is live exactly at the same time as all of its sub-buffers.
val live_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b /\ compatible_sub b i len sub_rel))
(ensures (live h b <==> (live h (mgsub sub_rel b i len) /\ (exists h0 . {:pattern (live h0 b)} live h0 b))))
[SMTPatOr [
[SMTPat (live h (mgsub sub_rel b i len))];
[SMTPat (live h b); SMTPat (mgsub sub_rel b i len);]
]]
val gsub_is_null (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (g_is_null (mgsub sub_rel b i len) <==> g_is_null b))
[SMTPat (g_is_null (mgsub sub_rel b i len))]
/// The length of a sub-buffer is exactly the one provided at ``gsub``.
val len_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len':U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len' <= length b))
(ensures (len (mgsub sub_rel b i len') == len'))
[SMTPatOr [
[SMTPat (len (mgsub sub_rel b i len'))];
[SMTPat (length (mgsub sub_rel b i len'))];
]]
val frameOf_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (frameOf (mgsub sub_rel b i len) == frameOf b))
[SMTPat (frameOf (mgsub sub_rel b i len))]
val as_addr_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_addr (mgsub sub_rel b i len) == as_addr b))
[SMTPat (as_addr (mgsub sub_rel b i len))]
val mgsub_inj (#a:Type0) (#rrel #rel:srel a) (sub_rel1 sub_rel2:srel a)
(b1 b2:mbuffer a rrel rel)
(i1 i2:U32.t)
(len1 len2:U32.t)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b1 /\
U32.v i2 + U32.v len2 <= length b2 /\
mgsub sub_rel1 b1 i1 len1 === mgsub sub_rel2 b2 i2 len2))
(ensures (len1 == len2 /\ (b1 == b2 ==> i1 == i2) /\ ((i1 == i2 /\ length b1 == length b2) ==> b1 == b2)))
/// Nesting two ``gsub`` collapses into one ``gsub``, transitively.
val gsub_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i1:U32.t) (len1:U32.t) (sub_rel1:srel a)
(i2: U32.t) (len2: U32.t) (sub_rel2:srel a)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b /\
U32.v i2 + U32.v len2 <= U32.v len1))
(ensures (((compatible_sub b i1 len1 sub_rel1 /\ compatible_sub (mgsub sub_rel1 b i1 len1) i2 len2 sub_rel2) ==> compatible_sub b (U32.add i1 i2) len2 sub_rel2) /\
mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2 == mgsub sub_rel2 b (U32.add i1 i2) len2))
[SMTPat (mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2)]
/// A buffer ``b`` is equal to its "largest" sub-buffer, at index 0 and
/// length ``len b``.
val gsub_zero_length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (compatible_sub b 0ul (len b) rel /\ b == mgsub rel b 0ul (len b))
/// The contents of a sub-buffer is the corresponding slice of the
/// contents of its enclosing buffer.
val as_seq_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_seq h (mgsub sub_rel b i len) == Seq.slice (as_seq h b) (U32.v i) (U32.v i + U32.v len)))
[SMTPat (as_seq h (mgsub sub_rel b i len))]
/// Two live non-null buffers having the same region and address have
/// their elements of the same type.
val live_same_addresses_equal_types_and_preorders
(#a1 #a2: Type0)
(#rrel1 #rel1: srel a1)
(#rrel2 #rel2: srel a2)
(b1: mbuffer a1 rrel1 rel1)
(b2: mbuffer a2 rrel2 rel2)
(h: HS.mem)
: Lemma
((frameOf b1 == frameOf b2 /\ as_addr b1 == as_addr b2 /\ live h b1 /\ live h b2 /\ (~ (g_is_null b1 /\ g_is_null b2))) ==> (a1 == a2 /\ rrel1 == rrel2))
/// # The modifies clause
///
/// The modifies clause for regions, references and buffers.
/// ==========================================================
///
/// This module presents the modifies clause, a way to track the set
/// of memory locations modified by a stateful Low* (or even F*)
/// program. The basic principle of modifies clauses is that any
/// location that is disjoint from a set of memory locations modified
/// by an operation is preserved by that operation.
///
/// We start by specifying a monoid of sets of memory locations. From
/// a rough high-level view, ``loc`` is the type of sets of memory
/// locations, equipped with an identity element ``loc_none``,
/// representing the empty set, and an associative and commutative
/// operator, ``loc_union``, representing the union of two sets of
/// memory locations.
///
/// Moreover, ``loc_union`` is idempotent, which is useful to cut SMT
/// matching loops with ``modifies_trans`` and ``modifies_refl`` below.
val loc : Type0
val loc_none: loc
val loc_union
(s1 s2: loc)
: GTot loc
val loc_union_idem
(s: loc)
: Lemma
(loc_union s s == s)
[SMTPat (loc_union s s)]
val loc_union_comm
(s1 s2: loc)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
[SMTPat (loc_union s1 s2)]
val loc_union_assoc
(s1 s2 s3: loc)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
let loc_union_idem_1
(s1 s2: loc)
: Lemma
(loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))]
= loc_union_assoc s1 s1 s2
let loc_union_idem_2
(s1 s2: loc)
: Lemma
(loc_union (loc_union s1 s2) s2 == loc_union s1 s2)
[SMTPat (loc_union (loc_union s1 s2) s2)]
= loc_union_assoc s1 s2 s2
val loc_union_loc_none_l
(s: loc)
: Lemma
(loc_union loc_none s == s)
[SMTPat (loc_union loc_none s)]
val loc_union_loc_none_r
(s: loc)
: Lemma
(loc_union s loc_none == s)
[SMTPat (loc_union s loc_none)]
/// ``loc_buffer b`` is the set of memory locations associated to a buffer ``b``.
val loc_buffer_from_to (#a:Type0) (#rrel #rel:srel a) (b: mbuffer a rrel rel) (from to: U32.t) : GTot loc
val loc_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc
val loc_buffer_eq (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) : Lemma
(loc_buffer b == loc_buffer_from_to b 0ul (len b))
val loc_buffer_from_to_high (#a: Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (length b <= U32.v to))
(ensures (loc_buffer_from_to b from to == loc_buffer_from_to b from (len b)))
val loc_buffer_from_to_none (#a: Type) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (g_is_null b \/ length b < U32.v from \/ U32.v to < U32.v from))
(ensures (loc_buffer_from_to b from to == loc_none))
val loc_buffer_from_to_mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
(from to: U32.t)
: Lemma
(requires (
U32.v i + U32.v len <= length b /\
U32.v from <= U32.v to /\ U32.v to <= U32.v len
))
(ensures (
loc_buffer_from_to (mgsub sub_rel b i len) from to == loc_buffer_from_to b (i `U32.add` from) (i `U32.add` to)
))
val loc_buffer_mgsub_eq (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub sub_rel b i len) == loc_buffer_from_to b i (i `U32.add` len)))
val loc_buffer_null (a:Type0) (rrel rel:srel a)
:Lemma (loc_buffer (mnull #a #rrel #rel) == loc_none)
[SMTPat (loc_buffer (mnull #a #rrel #rel))]
val loc_buffer_from_to_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(from to: U32.t)
: Lemma
(requires (U32.v from <= U32.v to /\ U32.v to <= length b))
(ensures (loc_buffer_from_to b from to == loc_buffer (mgsub rel b from (to `U32.sub` from))))
[SMTPat (loc_buffer_from_to b from to)]
val loc_buffer_mgsub_rel_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(rel1 rel2: srel a)
(i len: U32.t)
: Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub rel1 b i len) == loc_buffer (mgsub rel2 b i len)))
[SMTPat (loc_buffer (mgsub rel1 b i len)); SMTPat (loc_buffer (mgsub rel2 b i len))]
/// ``loc_addresses r n`` is the set of memory locations associated to a
/// set of addresses ``n`` in a given region ``r``.
val loc_addresses
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot loc
unfold let loc_addr_of_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc =
loc_addresses false (frameOf b) (Set.singleton (as_addr b))
/// ``loc_regions r`` is the set of memory locations associated to a set
/// ``r`` of regions.
val loc_regions
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot loc
/// ``loc_mreference b`` is the set of memory locations associated to a
/// reference ``b``, which is actually the set of memory locations
/// associated to the address of ``b``.
unfold
let loc_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
unfold
let loc_freed_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
/// ``loc_region_only r`` is the set of memory locations associated to a
/// region ``r`` but not any region ``r'`` that extends ``r`` (in the sense
/// of ``FStar.HyperStack.extends``.)
unfold
let loc_region_only
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (Set.singleton r)
/// ``loc_all_regions_from r`` is the set of all memory locations
/// associated to a region ``r`` and any region ``r'`` that transitively
/// extends ``r`` (in the sense of ``FStar.HyperStack.extends``,
/// e.g. nested stack frames.)
unfold
let loc_all_regions_from
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (HS.mod_set (Set.singleton r))
/// We equip the ``loc`` monoid of sets of memory locations with an
/// inclusion relation, ``loc_includes``, which is a preorder compatible
/// with ``loc_union``. Although we consider sets of memory locations,
/// we do not specify them using any F* set library such as
/// ``FStar.Set``, ``FStar.TSet`` or ``FStar.GSet``, because ``loc_includes``
/// encompasses more than just set-theoretic inclusion.
val loc_includes
(s1 s2: loc)
: GTot Type0
val loc_includes_refl
(s: loc)
: Lemma
(loc_includes s s)
[SMTPat (loc_includes s s)]
val loc_includes_trans
(s1 s2 s3: loc)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
let loc_includes_trans_backwards
(s1 s2 s3: loc)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
[SMTPat (loc_includes s1 s3); SMTPat (loc_includes s2 s3)]
= loc_includes_trans s1 s2 s3
val loc_includes_union_r
(s s1 s2: loc)
: Lemma
(requires (loc_includes s s1 /\ loc_includes s s2))
(ensures (loc_includes s (loc_union s1 s2)))
val loc_includes_union_l
(s1 s2 s: loc)
: Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.ModifiesGen",
"short_module": "MG"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s1: LowStar.Monotonic.Buffer.loc ->
s2: LowStar.Monotonic.Buffer.loc ->
s: LowStar.Monotonic.Buffer.loc
-> FStar.Pervasives.Lemma
(requires
LowStar.Monotonic.Buffer.loc_includes s1 s \/ LowStar.Monotonic.Buffer.loc_includes s2 s)
(ensures LowStar.Monotonic.Buffer.loc_includes (LowStar.Monotonic.Buffer.loc_union s1 s2) s)
[SMTPat (LowStar.Monotonic.Buffer.loc_includes (LowStar.Monotonic.Buffer.loc_union s1 s2) s)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowStar.Monotonic.Buffer.loc",
"LowStar.Monotonic.Buffer.loc_includes_union_l",
"Prims.unit",
"Prims.l_or",
"LowStar.Monotonic.Buffer.loc_includes",
"Prims.squash",
"LowStar.Monotonic.Buffer.loc_union",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | true | false | true | false | false | let loc_includes_union_l' (s1 s2 s: loc)
: Lemma (requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
[SMTPat (loc_includes (loc_union s1 s2) s)] =
| loc_includes_union_l s1 s2 s | false |
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.compatible_subseq_preorder | val compatible_subseq_preorder : len: Prims.nat ->
rel: LowStar.Monotonic.Buffer.srel a ->
i: Prims.nat ->
j: Prims.nat{i <= j /\ j <= len} ->
sub_rel: LowStar.Monotonic.Buffer.srel a
-> Prims.logical | let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 50,
"end_line": 45,
"start_col": 0,
"start_line": 38
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Prims.nat ->
rel: LowStar.Monotonic.Buffer.srel a ->
i: Prims.nat ->
j: Prims.nat{i <= j /\ j <= len} ->
sub_rel: LowStar.Monotonic.Buffer.srel a
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"LowStar.Monotonic.Buffer.srel",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_Forall",
"FStar.Seq.Base.seq",
"Prims.l_imp",
"Prims.eq2",
"FStar.Seq.Base.length",
"FStar.Seq.Base.slice",
"Prims.int",
"Prims.op_Subtraction",
"FStar.Seq.Properties.replace_subseq",
"Prims.logical"
] | [] | false | false | false | false | true | let compatible_subseq_preorder
(#a: Type0)
(len: nat)
(rel: srel a)
(i: nat)
(j: nat{i <= j /\ j <= len})
(sub_rel: srel a)
=
| (forall (s1: Seq.seq a) (s2: Seq.seq a).
{:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))}
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==>
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\
(forall (s: Seq.seq a) (s2: Seq.seq a).
{:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))}
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==>
(rel s (Seq.replace_subseq s i j s2))) | false |
|
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.loc_includes_trans_backwards | val loc_includes_trans_backwards (s1 s2 s3: loc)
: Lemma (requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
[SMTPat (loc_includes s1 s3); SMTPat (loc_includes s2 s3)] | val loc_includes_trans_backwards (s1 s2 s3: loc)
: Lemma (requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
[SMTPat (loc_includes s1 s3); SMTPat (loc_includes s2 s3)] | let loc_includes_trans_backwards
(s1 s2 s3: loc)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
[SMTPat (loc_includes s1 s3); SMTPat (loc_includes s2 s3)]
= loc_includes_trans s1 s2 s3 | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 29,
"end_line": 622,
"start_col": 0,
"start_line": 616
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul)
let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b
let length_null_2 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true)) (ensures (length b == 0))
[SMTPat (g_is_null b)]
= len_null a rrel rel;
null_unique b
/// For functional correctness, buffers are reflected at the proof
/// level using sequences, via ``as_seq b h``, which returns the
/// contents of a given buffer ``b`` in a given heap ``h``. If ``b`` is not
/// live in ``h``, then the result is unspecified.
(* TODO: why not return a lseq and remove length_as_seq lemma? *)
val as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot (Seq.seq a)
/// The contents of a buffer ``b`` has the same length as ``b`` itself.
val length_as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (Seq.length (as_seq h b) == length b)
[SMTPat (Seq.length (as_seq h b))]
/// ``get`` is an often-convenient shorthand to index the value of a
/// given buffer in a given heap, for proof purposes.
let get (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (p:mbuffer a rrel rel) (i:nat)
:Ghost a (requires (i < length p)) (ensures (fun _ -> True))
= Seq.index (as_seq h p) i
/// Injectivity in the first preorder
val mbuffer_injectivity_in_first_preorder (_:unit)
: Lemma (forall (a:Type0) (rrel1 rrel2 rel1 rel2:srel a)
(b1:mbuffer a rrel1 rel1)
(b2:mbuffer a rrel2 rel2).
rrel1 =!= rrel2 ==> ~ (b1 === b2))
/// Before defining sub-buffer related API, we need to define the notion of "compatibility"
///
///
/// Sub-buffers can be taken at a different preorder than their parent buffers
/// But we need to ensure that the changes to the sub-buffer are compatible with the preorder
/// of the parent buffer, and vice versa.
(*
* The quantifiers are fiercely guarded, so if you are working directly with them,
* you may have to write additional asserts as triggers
*)
[@@"opaque_to_smt"]
unfold let compatible_sub
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t{U32.v i + U32.v len <= length b}) (sub_rel:srel a)
= compatible_subseq_preorder (length b) rel (U32.v i) (U32.v i + U32.v len) sub_rel
/// ``gsub`` is the way to carve a sub-buffer out of a given
/// buffer. ``gsub b i len`` return the sub-buffer of ``b`` starting from
/// offset ``i`` within ``b``, and with length ``len``. Of course ``i`` and
/// ``len`` must fit within the length of ``b``.
///
/// Further the clients can attach a preorder with the subbuffer (sub_rel),
/// provided it is compatible
///
/// ``gsub`` is the ghost version, for proof purposes. Its stateful
/// counterpart is ``sub``, see below.
val mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Ghost (mbuffer a rrel sub_rel)
(requires (U32.v i + U32.v len <= length b))
(ensures (fun _ -> True))
// goffset
/// A buffer is live exactly at the same time as all of its sub-buffers.
val live_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b /\ compatible_sub b i len sub_rel))
(ensures (live h b <==> (live h (mgsub sub_rel b i len) /\ (exists h0 . {:pattern (live h0 b)} live h0 b))))
[SMTPatOr [
[SMTPat (live h (mgsub sub_rel b i len))];
[SMTPat (live h b); SMTPat (mgsub sub_rel b i len);]
]]
val gsub_is_null (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (g_is_null (mgsub sub_rel b i len) <==> g_is_null b))
[SMTPat (g_is_null (mgsub sub_rel b i len))]
/// The length of a sub-buffer is exactly the one provided at ``gsub``.
val len_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len':U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len' <= length b))
(ensures (len (mgsub sub_rel b i len') == len'))
[SMTPatOr [
[SMTPat (len (mgsub sub_rel b i len'))];
[SMTPat (length (mgsub sub_rel b i len'))];
]]
val frameOf_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (frameOf (mgsub sub_rel b i len) == frameOf b))
[SMTPat (frameOf (mgsub sub_rel b i len))]
val as_addr_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_addr (mgsub sub_rel b i len) == as_addr b))
[SMTPat (as_addr (mgsub sub_rel b i len))]
val mgsub_inj (#a:Type0) (#rrel #rel:srel a) (sub_rel1 sub_rel2:srel a)
(b1 b2:mbuffer a rrel rel)
(i1 i2:U32.t)
(len1 len2:U32.t)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b1 /\
U32.v i2 + U32.v len2 <= length b2 /\
mgsub sub_rel1 b1 i1 len1 === mgsub sub_rel2 b2 i2 len2))
(ensures (len1 == len2 /\ (b1 == b2 ==> i1 == i2) /\ ((i1 == i2 /\ length b1 == length b2) ==> b1 == b2)))
/// Nesting two ``gsub`` collapses into one ``gsub``, transitively.
val gsub_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i1:U32.t) (len1:U32.t) (sub_rel1:srel a)
(i2: U32.t) (len2: U32.t) (sub_rel2:srel a)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b /\
U32.v i2 + U32.v len2 <= U32.v len1))
(ensures (((compatible_sub b i1 len1 sub_rel1 /\ compatible_sub (mgsub sub_rel1 b i1 len1) i2 len2 sub_rel2) ==> compatible_sub b (U32.add i1 i2) len2 sub_rel2) /\
mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2 == mgsub sub_rel2 b (U32.add i1 i2) len2))
[SMTPat (mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2)]
/// A buffer ``b`` is equal to its "largest" sub-buffer, at index 0 and
/// length ``len b``.
val gsub_zero_length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (compatible_sub b 0ul (len b) rel /\ b == mgsub rel b 0ul (len b))
/// The contents of a sub-buffer is the corresponding slice of the
/// contents of its enclosing buffer.
val as_seq_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_seq h (mgsub sub_rel b i len) == Seq.slice (as_seq h b) (U32.v i) (U32.v i + U32.v len)))
[SMTPat (as_seq h (mgsub sub_rel b i len))]
/// Two live non-null buffers having the same region and address have
/// their elements of the same type.
val live_same_addresses_equal_types_and_preorders
(#a1 #a2: Type0)
(#rrel1 #rel1: srel a1)
(#rrel2 #rel2: srel a2)
(b1: mbuffer a1 rrel1 rel1)
(b2: mbuffer a2 rrel2 rel2)
(h: HS.mem)
: Lemma
((frameOf b1 == frameOf b2 /\ as_addr b1 == as_addr b2 /\ live h b1 /\ live h b2 /\ (~ (g_is_null b1 /\ g_is_null b2))) ==> (a1 == a2 /\ rrel1 == rrel2))
/// # The modifies clause
///
/// The modifies clause for regions, references and buffers.
/// ==========================================================
///
/// This module presents the modifies clause, a way to track the set
/// of memory locations modified by a stateful Low* (or even F*)
/// program. The basic principle of modifies clauses is that any
/// location that is disjoint from a set of memory locations modified
/// by an operation is preserved by that operation.
///
/// We start by specifying a monoid of sets of memory locations. From
/// a rough high-level view, ``loc`` is the type of sets of memory
/// locations, equipped with an identity element ``loc_none``,
/// representing the empty set, and an associative and commutative
/// operator, ``loc_union``, representing the union of two sets of
/// memory locations.
///
/// Moreover, ``loc_union`` is idempotent, which is useful to cut SMT
/// matching loops with ``modifies_trans`` and ``modifies_refl`` below.
val loc : Type0
val loc_none: loc
val loc_union
(s1 s2: loc)
: GTot loc
val loc_union_idem
(s: loc)
: Lemma
(loc_union s s == s)
[SMTPat (loc_union s s)]
val loc_union_comm
(s1 s2: loc)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
[SMTPat (loc_union s1 s2)]
val loc_union_assoc
(s1 s2 s3: loc)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
let loc_union_idem_1
(s1 s2: loc)
: Lemma
(loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))]
= loc_union_assoc s1 s1 s2
let loc_union_idem_2
(s1 s2: loc)
: Lemma
(loc_union (loc_union s1 s2) s2 == loc_union s1 s2)
[SMTPat (loc_union (loc_union s1 s2) s2)]
= loc_union_assoc s1 s2 s2
val loc_union_loc_none_l
(s: loc)
: Lemma
(loc_union loc_none s == s)
[SMTPat (loc_union loc_none s)]
val loc_union_loc_none_r
(s: loc)
: Lemma
(loc_union s loc_none == s)
[SMTPat (loc_union s loc_none)]
/// ``loc_buffer b`` is the set of memory locations associated to a buffer ``b``.
val loc_buffer_from_to (#a:Type0) (#rrel #rel:srel a) (b: mbuffer a rrel rel) (from to: U32.t) : GTot loc
val loc_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc
val loc_buffer_eq (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) : Lemma
(loc_buffer b == loc_buffer_from_to b 0ul (len b))
val loc_buffer_from_to_high (#a: Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (length b <= U32.v to))
(ensures (loc_buffer_from_to b from to == loc_buffer_from_to b from (len b)))
val loc_buffer_from_to_none (#a: Type) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (g_is_null b \/ length b < U32.v from \/ U32.v to < U32.v from))
(ensures (loc_buffer_from_to b from to == loc_none))
val loc_buffer_from_to_mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
(from to: U32.t)
: Lemma
(requires (
U32.v i + U32.v len <= length b /\
U32.v from <= U32.v to /\ U32.v to <= U32.v len
))
(ensures (
loc_buffer_from_to (mgsub sub_rel b i len) from to == loc_buffer_from_to b (i `U32.add` from) (i `U32.add` to)
))
val loc_buffer_mgsub_eq (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub sub_rel b i len) == loc_buffer_from_to b i (i `U32.add` len)))
val loc_buffer_null (a:Type0) (rrel rel:srel a)
:Lemma (loc_buffer (mnull #a #rrel #rel) == loc_none)
[SMTPat (loc_buffer (mnull #a #rrel #rel))]
val loc_buffer_from_to_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(from to: U32.t)
: Lemma
(requires (U32.v from <= U32.v to /\ U32.v to <= length b))
(ensures (loc_buffer_from_to b from to == loc_buffer (mgsub rel b from (to `U32.sub` from))))
[SMTPat (loc_buffer_from_to b from to)]
val loc_buffer_mgsub_rel_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(rel1 rel2: srel a)
(i len: U32.t)
: Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub rel1 b i len) == loc_buffer (mgsub rel2 b i len)))
[SMTPat (loc_buffer (mgsub rel1 b i len)); SMTPat (loc_buffer (mgsub rel2 b i len))]
/// ``loc_addresses r n`` is the set of memory locations associated to a
/// set of addresses ``n`` in a given region ``r``.
val loc_addresses
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot loc
unfold let loc_addr_of_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc =
loc_addresses false (frameOf b) (Set.singleton (as_addr b))
/// ``loc_regions r`` is the set of memory locations associated to a set
/// ``r`` of regions.
val loc_regions
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot loc
/// ``loc_mreference b`` is the set of memory locations associated to a
/// reference ``b``, which is actually the set of memory locations
/// associated to the address of ``b``.
unfold
let loc_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
unfold
let loc_freed_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
/// ``loc_region_only r`` is the set of memory locations associated to a
/// region ``r`` but not any region ``r'`` that extends ``r`` (in the sense
/// of ``FStar.HyperStack.extends``.)
unfold
let loc_region_only
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (Set.singleton r)
/// ``loc_all_regions_from r`` is the set of all memory locations
/// associated to a region ``r`` and any region ``r'`` that transitively
/// extends ``r`` (in the sense of ``FStar.HyperStack.extends``,
/// e.g. nested stack frames.)
unfold
let loc_all_regions_from
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (HS.mod_set (Set.singleton r))
/// We equip the ``loc`` monoid of sets of memory locations with an
/// inclusion relation, ``loc_includes``, which is a preorder compatible
/// with ``loc_union``. Although we consider sets of memory locations,
/// we do not specify them using any F* set library such as
/// ``FStar.Set``, ``FStar.TSet`` or ``FStar.GSet``, because ``loc_includes``
/// encompasses more than just set-theoretic inclusion.
val loc_includes
(s1 s2: loc)
: GTot Type0
val loc_includes_refl
(s: loc)
: Lemma
(loc_includes s s)
[SMTPat (loc_includes s s)]
val loc_includes_trans
(s1 s2 s3: loc)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.ModifiesGen",
"short_module": "MG"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s1: LowStar.Monotonic.Buffer.loc ->
s2: LowStar.Monotonic.Buffer.loc ->
s3: LowStar.Monotonic.Buffer.loc
-> FStar.Pervasives.Lemma
(requires
LowStar.Monotonic.Buffer.loc_includes s1 s2 /\ LowStar.Monotonic.Buffer.loc_includes s2 s3)
(ensures LowStar.Monotonic.Buffer.loc_includes s1 s3)
[
SMTPat (LowStar.Monotonic.Buffer.loc_includes s1 s3);
SMTPat (LowStar.Monotonic.Buffer.loc_includes s2 s3)
] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowStar.Monotonic.Buffer.loc",
"LowStar.Monotonic.Buffer.loc_includes_trans",
"Prims.unit",
"Prims.l_and",
"LowStar.Monotonic.Buffer.loc_includes",
"Prims.squash",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | true | false | true | false | false | let loc_includes_trans_backwards (s1 s2 s3: loc)
: Lemma (requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
[SMTPat (loc_includes s1 s3); SMTPat (loc_includes s2 s3)] =
| loc_includes_trans s1 s2 s3 | false |
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.live_is_null | val live_is_null (#a: Type0) (#rrel #rel: srel a) (h: HS.mem) (b: mbuffer a rrel rel)
: Lemma (requires (g_is_null b == true)) (ensures (live h b)) [SMTPat (live h b)] | val live_is_null (#a: Type0) (#rrel #rel: srel a) (h: HS.mem) (b: mbuffer a rrel rel)
: Lemma (requires (g_is_null b == true)) (ensures (live h b)) [SMTPat (live h b)] | let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 124,
"start_col": 0,
"start_line": 119
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> b: LowStar.Monotonic.Buffer.mbuffer a rrel rel
-> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.g_is_null b == true)
(ensures LowStar.Monotonic.Buffer.live h b)
[SMTPat (LowStar.Monotonic.Buffer.live h b)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowStar.Monotonic.Buffer.srel",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Monotonic.Buffer.live_null",
"Prims.unit",
"LowStar.Monotonic.Buffer.null_unique",
"Prims.eq2",
"Prims.bool",
"LowStar.Monotonic.Buffer.g_is_null",
"Prims.squash",
"LowStar.Monotonic.Buffer.live",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | true | false | true | false | false | let live_is_null (#a: Type0) (#rrel #rel: srel a) (h: HS.mem) (b: mbuffer a rrel rel)
: Lemma (requires (g_is_null b == true)) (ensures (live h b)) [SMTPat (live h b)] =
| null_unique b;
live_null a rrel rel h | false |
Vale.Transformers.BoundedInstructionEffects.fsti | Vale.Transformers.BoundedInstructionEffects.add_r_to_rw_set | val add_r_to_rw_set (r: locations) (rw: rw_set) : rw_set | val add_r_to_rw_set (r: locations) (rw: rw_set) : rw_set | let add_r_to_rw_set (r:locations) (rw:rw_set) : rw_set =
{ rw with loc_reads = r `L.append` rw.loc_reads } | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 131,
"start_col": 0,
"start_line": 130
} | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Machine_s
open Vale.X64.Machine_Semantics_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
module L = FStar.List.Tot
(** A [location_with_value] contains a location and the value it must hold *)
type location_with_value = l:location_eq & location_val_eqt l
(** A [locations_with_values] contains locations and values they must hold *)
type locations_with_values = list location_with_value
(** An [rw_set] contains information about what locations are read and
written by a stateful operation. *)
type rw_set = {
loc_reads: locations;
loc_writes: locations;
loc_constant_writes: locations_with_values;
}
(** [rw_set_of_ins i] returns the read/write sets for the execution of
an instruction. *)
val rw_set_of_ins : i:ins -> rw_set
(** [locations_of_ocmp o] returns the read set for a comparison operator. *)
val locations_of_ocmp : o:ocmp -> locations
(** [unchanged_except exc s1 s2] means all locations that are disjoint
from the exceptions [exc] have the same value in both [s1] and [s2]. *)
let unchanged_except (exceptions:locations) (s1 s2:machine_state) :
GTot Type0 =
(forall (a:location). {:pattern (eval_location a s2)} (
(!!(disjoint_location_from_locations a exceptions) ==>
(eval_location a s1 == eval_location a s2))
))
(** [only_affects locs f] means that running [f] leaves everything
except [locs] unchanged. *)
let only_affects (locs:locations) (f:st unit) : GTot Type0 =
forall s. {:pattern unchanged_except locs s (run f s)} (
(run f s).ms_ok ==> unchanged_except locs s (run f s)
)
(** [unchanged_at locs s1 s2] means the the value of any location in
[locs] is same in both [s1] and [s2]. *)
let rec unchanged_at (locs:locations) (s1 s2:machine_state) : GTot Type0 =
match locs with
| [] -> True
| x :: xs -> (
(eval_location x s1 == eval_location x s2) /\
(unchanged_at xs s1 s2)
)
(** [constant_on_execution locv f s] means that running [f] on [s]
ensures that the values of the locations in [locv] always match
the values given to them in [locv]. *)
let rec constant_on_execution (locv:locations_with_values) (f:st unit) (s:machine_state) : GTot Type0 =
(run f s).ms_ok ==> (
match locv with
| [] -> True
| (|l, v|) :: xs -> (
(eval_location l (run f s) == raise_location_val_eqt v) /\
(constant_on_execution xs f s)
)
)
(** [bounded_effects rw f] means that the execution of [f] is bounded
by the read-write [rw]. This means that whenever two different
states are same at the locations in [rw.loc_reads], then the
function will have the same effect, and that its effect is bounded
to the set [rw.loc_writes]. Additionally, execution always causes
the resultant state to cause the results to be written as per
[rw.loc_constant_writes]. *)
let bounded_effects (rw:rw_set) (f:st unit) : GTot Type0 =
(only_affects rw.loc_writes f) /\
(forall s. {:pattern (constant_on_execution rw.loc_constant_writes f s)}
constant_on_execution rw.loc_constant_writes f s) /\
(forall l v. {:pattern (L.mem (|l,v|) rw.loc_constant_writes); (L.mem l rw.loc_writes)}
L.mem (|l,v|) rw.loc_constant_writes ==> L.mem l rw.loc_writes) /\
(
forall s1 s2. {:pattern (run f s1); (run f s2)} (
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2) ==> (
((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==>
unchanged_at rw.loc_writes (run f s1) (run f s2))
)
)
)
(** Safely bounded instructions are instructions that we can guarantee
[bounded_effects] upon their execution. For the rest of the
instructions, we currently don't have proofs about
[bounded_effects] for them. *)
let safely_bounded (i:ins) =
Instr? i
(** The evaluation of an instruction [i] is bounded by the read/write
set given by [rw_set_of_ins i]. *)
val lemma_machine_eval_ins_st_bounded_effects :
(i:ins) ->
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i))))
(** The evaluation of a [code] which is just an instruction [i] is
bounded by the read/write set given by [rw_set_of_ins i]. *)
val lemma_machine_eval_code_Ins_bounded_effects :
(i:ins) ->
(fuel:nat) ->
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s))))))
(** The evaluation of a comparison [o] depends solely upon its
locations, given by [locations_of_ocmp o] *)
val lemma_locations_of_ocmp : o:ocmp -> s1:machine_state -> s2:machine_state ->
Lemma
(requires (unchanged_at (locations_of_ocmp o) s1 s2))
(ensures (eval_ocmp s1 o == eval_ocmp s2 o)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fsti.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: Vale.Transformers.Locations.locations -> rw: Vale.Transformers.BoundedInstructionEffects.rw_set
-> Vale.Transformers.BoundedInstructionEffects.rw_set | Prims.Tot | [
"total"
] | [] | [
"Vale.Transformers.Locations.locations",
"Vale.Transformers.BoundedInstructionEffects.rw_set",
"Vale.Transformers.BoundedInstructionEffects.Mkrw_set",
"FStar.List.Tot.Base.append",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_constant_writes"
] | [] | false | false | false | true | false | let add_r_to_rw_set (r: locations) (rw: rw_set) : rw_set =
| { rw with loc_reads = r `L.append` rw.loc_reads } | false |
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.length_null_1 | val length_null_1 (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel)
: Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false)) [SMTPat (length b)] | val length_null_1 (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel)
: Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false)) [SMTPat (length b)] | let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 217,
"start_col": 0,
"start_line": 213
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: LowStar.Monotonic.Buffer.mbuffer a rrel rel
-> FStar.Pervasives.Lemma (requires ~(LowStar.Monotonic.Buffer.length b == 0))
(ensures LowStar.Monotonic.Buffer.g_is_null b == false)
[SMTPat (LowStar.Monotonic.Buffer.length b)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Monotonic.Buffer.null_unique",
"Prims.unit",
"LowStar.Monotonic.Buffer.len_null",
"Prims.l_not",
"Prims.eq2",
"Prims.int",
"LowStar.Monotonic.Buffer.length",
"Prims.squash",
"Prims.bool",
"LowStar.Monotonic.Buffer.g_is_null",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.nat",
"Prims.Nil"
] | [] | true | false | true | false | false | let length_null_1 (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel)
: Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false)) [SMTPat (length b)] =
| len_null a rrel rel;
null_unique b | false |
Hacl.Spec.PrecompBaseTable256.fst | Hacl.Spec.PrecompBaseTable256.a_pow2_128_lemma | val a_pow2_128_lemma: #t:Type -> k:SE.concrete_ops t -> a:t ->
Lemma (k.SE.to.SE.refl (a_pow2_128 k a) ==
LE.pow k.SE.to.SE.comm_monoid (k.SE.to.SE.refl a) (pow2 128)) | val a_pow2_128_lemma: #t:Type -> k:SE.concrete_ops t -> a:t ->
Lemma (k.SE.to.SE.refl (a_pow2_128 k a) ==
LE.pow k.SE.to.SE.comm_monoid (k.SE.to.SE.refl a) (pow2 128)) | let a_pow2_128_lemma #t k a =
let cm = k.SE.to.SE.comm_monoid in
let refl = k.SE.to.SE.refl in
calc (==) {
refl (a_pow2_128 k a);
(==) { }
refl (SE.exp_pow2 k (a_pow2_64 k a) 64);
(==) { a_pow2_64_lemma k (a_pow2_64 k a) }
LE.pow cm (refl (a_pow2_64 k a)) (pow2 64);
(==) { a_pow2_64_lemma k a }
LE.pow cm (LE.pow cm (refl a) (pow2 64)) (pow2 64);
(==) { LE.lemma_pow_mul cm (refl a) (pow2 64) (pow2 64) }
LE.pow cm (refl a) (pow2 64 * pow2 64);
(==) { Math.Lemmas.pow2_plus 64 64 }
LE.pow cm (refl a) (pow2 128);
} | {
"file_name": "code/bignum/Hacl.Spec.PrecompBaseTable256.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 125,
"start_col": 0,
"start_line": 110
} | module Hacl.Spec.PrecompBaseTable256
open FStar.Mul
open Lib.IntTypes
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module BD = Hacl.Spec.Bignum.Definitions
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lemma_mod_pow2_sub x a b =
calc (==) {
x / pow2 a % pow2 b * pow2 a;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 x a (a + b) }
x % pow2 (a + b) / pow2 a * pow2 a;
(==) { Math.Lemmas.euclidean_division_definition (x % pow2 (a + b)) (pow2 a) }
x % pow2 (a + b) - x % pow2 (a + b) % pow2 a;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 x a (a + b) }
x % pow2 (a + b) - x % pow2 a;
}
let lemma_decompose_nat256_as_four_u64 x =
let x0 = x % pow2 64 in
let x1 = x / pow2 64 % pow2 64 in
let x2 = x / pow2 128 % pow2 64 in
let x3' = x / pow2 192 % pow2 64 in
Math.Lemmas.lemma_div_lt x 256 192;
Math.Lemmas.small_mod (x / pow2 192) (pow2 64);
let x3 = x / pow2 192 in
assert (x3 == x3');
calc (==) {
x0 + x1 * pow2 64 + x2 * pow2 128 + x3 * pow2 192;
(==) { }
x0 + x1 * pow2 64 + (x / pow2 128 % pow2 64) * pow2 128 + x / pow2 192 * pow2 192;
(==) { lemma_mod_pow2_sub x 128 64 }
x0 + x1 * pow2 64 + x % pow2 192 - x % pow2 128 + x / pow2 192 * pow2 192;
(==) { Math.Lemmas.euclidean_division_definition x (pow2 192) }
x0 + x1 * pow2 64 - x % pow2 128 + x;
(==) { lemma_mod_pow2_sub x 64 64 }
x;
}
let lemma_point_mul_base_precomp4 #t k a b =
let (b0, b1, b2, b3) = decompose_nat256_as_four_u64 b in
let a_pow2_64 = LE.pow k a (pow2 64) in
let a_pow2_128 = LE.pow k a (pow2 128) in
let a_pow2_192 = LE.pow k a (pow2 192) in
let res = LE.exp_four_fw k a 64 b0 a_pow2_64 b1 a_pow2_128 b2 a_pow2_192 b3 4 in
calc (==) {
LE.exp_four_fw k a 64 b0 a_pow2_64 b1 a_pow2_128 b2 a_pow2_192 b3 4;
(==) { LE.exp_four_fw_lemma k a 64 b0 a_pow2_64 b1 a_pow2_128 b2 a_pow2_192 b3 4 }
k.LE.mul
(k.LE.mul
(k.LE.mul (LE.pow k a b0) (LE.pow k (LE.pow k a (pow2 64)) b1))
(LE.pow k a_pow2_128 b2))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_mul k a (pow2 64) b1 }
k.LE.mul
(k.LE.mul
(k.LE.mul (LE.pow k a b0) (LE.pow k a (b1 * pow2 64)))
(LE.pow k a_pow2_128 b2))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_add k a b0 (b1 * pow2 64) }
k.LE.mul
(k.LE.mul
(LE.pow k a (b0 + b1 * pow2 64))
(LE.pow k (LE.pow k a (pow2 128)) b2))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_mul k a (pow2 128) b2 }
k.LE.mul
(k.LE.mul (LE.pow k a (b0 + b1 * pow2 64)) (LE.pow k a (b2 * pow2 128)))
(LE.pow k a_pow2_192 b3);
(==) { LE.lemma_pow_add k a (b0 + b1 * pow2 64) (b2 * pow2 128) }
k.LE.mul
(LE.pow k a (b0 + b1 * pow2 64 + b2 * pow2 128))
(LE.pow k (LE.pow k a (pow2 192)) b3);
(==) { LE.lemma_pow_mul k a (pow2 192) b3 }
k.LE.mul
(LE.pow k a (b0 + b1 * pow2 64 + b2 * pow2 128))
(LE.pow k a (b3 * pow2 192));
(==) { LE.lemma_pow_add k a (b0 + b1 * pow2 64 + b2 * pow2 128) (b3 * pow2 192) }
LE.pow k a (b0 + b1 * pow2 64 + b2 * pow2 128 + b3 * pow2 192);
(==) { lemma_decompose_nat256_as_four_u64 b }
LE.pow k a b;
}
//-----------------------
#push-options "--fuel 2"
let rec exp_pow2_rec_is_exp_pow2 #t k a b =
if b = 0 then Lib.LoopCombinators.eq_repeat0 k.sqr a
else begin
Lib.LoopCombinators.unfold_repeat b k.sqr a (b - 1);
assert (Loops.repeat b k.sqr a == k.sqr (Loops.repeat (b - 1) k.sqr a));
exp_pow2_rec_is_exp_pow2 k a (b - 1) end
#pop-options
let a_pow2_64_lemma #t k a =
SE.exp_pow2_lemma k a 64;
LE.exp_pow2_lemma k.SE.to.SE.comm_monoid (k.SE.to.SE.refl a) 64 | {
"checked_file": "/",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Spec.PrecompBaseTable256.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Spec.Exponentiation.concrete_ops t -> a: t
-> FStar.Pervasives.Lemma
(ensures
Mkto_comm_monoid?.refl (Mkconcrete_ops?.to k) (Hacl.Spec.PrecompBaseTable256.a_pow2_128 k a) ==
Lib.Exponentiation.Definition.pow (Mkto_comm_monoid?.comm_monoid (Mkconcrete_ops?.to k))
(Mkto_comm_monoid?.refl (Mkconcrete_ops?.to k) a)
(Prims.pow2 128)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"FStar.Calc.calc_finish",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__to",
"Prims.eq2",
"Hacl.Spec.PrecompBaseTable256.a_pow2_128",
"Lib.Exponentiation.Definition.pow",
"Prims.pow2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Mul.op_Star",
"Hacl.Spec.PrecompBaseTable256.a_pow2_64",
"Spec.Exponentiation.exp_pow2",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Hacl.Spec.PrecompBaseTable256.a_pow2_64_lemma",
"Lib.Exponentiation.Definition.lemma_pow_mul",
"FStar.Math.Lemmas.pow2_plus",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__refl",
"Lib.Exponentiation.Definition.comm_monoid",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid"
] | [] | false | false | true | false | false | let a_pow2_128_lemma #t k a =
| let cm = k.SE.to.SE.comm_monoid in
let refl = k.SE.to.SE.refl in
calc ( == ) {
refl (a_pow2_128 k a);
( == ) { () }
refl (SE.exp_pow2 k (a_pow2_64 k a) 64);
( == ) { a_pow2_64_lemma k (a_pow2_64 k a) }
LE.pow cm (refl (a_pow2_64 k a)) (pow2 64);
( == ) { a_pow2_64_lemma k a }
LE.pow cm (LE.pow cm (refl a) (pow2 64)) (pow2 64);
( == ) { LE.lemma_pow_mul cm (refl a) (pow2 64) (pow2 64) }
LE.pow cm (refl a) (pow2 64 * pow2 64);
( == ) { Math.Lemmas.pow2_plus 64 64 }
LE.pow cm (refl a) (pow2 128);
} | false |
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.length_null_2 | val length_null_2 (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel)
: Lemma (requires (g_is_null b == true)) (ensures (length b == 0)) [SMTPat (g_is_null b)] | val length_null_2 (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel)
: Lemma (requires (g_is_null b == true)) (ensures (length b == 0)) [SMTPat (g_is_null b)] | let length_null_2 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true)) (ensures (length b == 0))
[SMTPat (g_is_null b)]
= len_null a rrel rel;
null_unique b | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 223,
"start_col": 0,
"start_line": 219
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul)
let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: LowStar.Monotonic.Buffer.mbuffer a rrel rel
-> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.g_is_null b == true)
(ensures LowStar.Monotonic.Buffer.length b == 0)
[SMTPat (LowStar.Monotonic.Buffer.g_is_null b)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Monotonic.Buffer.null_unique",
"Prims.unit",
"LowStar.Monotonic.Buffer.len_null",
"Prims.eq2",
"Prims.bool",
"LowStar.Monotonic.Buffer.g_is_null",
"Prims.squash",
"Prims.int",
"LowStar.Monotonic.Buffer.length",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | true | false | true | false | false | let length_null_2 (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel)
: Lemma (requires (g_is_null b == true)) (ensures (length b == 0)) [SMTPat (g_is_null b)] =
| len_null a rrel rel;
null_unique b | false |
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.compatible_sub | val compatible_sub : b: LowStar.Monotonic.Buffer.mbuffer a rrel rel ->
i: FStar.UInt32.t ->
len: FStar.UInt32.t{FStar.UInt32.v i + FStar.UInt32.v len <= LowStar.Monotonic.Buffer.length b} ->
sub_rel: LowStar.Monotonic.Buffer.srel a
-> Prims.logical | let compatible_sub
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t{U32.v i + U32.v len <= length b}) (sub_rel:srel a)
= compatible_subseq_preorder (length b) rel (U32.v i) (U32.v i + U32.v len) sub_rel | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 85,
"end_line": 273,
"start_col": 7,
"start_line": 270
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul)
let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b
let length_null_2 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true)) (ensures (length b == 0))
[SMTPat (g_is_null b)]
= len_null a rrel rel;
null_unique b
/// For functional correctness, buffers are reflected at the proof
/// level using sequences, via ``as_seq b h``, which returns the
/// contents of a given buffer ``b`` in a given heap ``h``. If ``b`` is not
/// live in ``h``, then the result is unspecified.
(* TODO: why not return a lseq and remove length_as_seq lemma? *)
val as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot (Seq.seq a)
/// The contents of a buffer ``b`` has the same length as ``b`` itself.
val length_as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (Seq.length (as_seq h b) == length b)
[SMTPat (Seq.length (as_seq h b))]
/// ``get`` is an often-convenient shorthand to index the value of a
/// given buffer in a given heap, for proof purposes.
let get (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (p:mbuffer a rrel rel) (i:nat)
:Ghost a (requires (i < length p)) (ensures (fun _ -> True))
= Seq.index (as_seq h p) i
/// Injectivity in the first preorder
val mbuffer_injectivity_in_first_preorder (_:unit)
: Lemma (forall (a:Type0) (rrel1 rrel2 rel1 rel2:srel a)
(b1:mbuffer a rrel1 rel1)
(b2:mbuffer a rrel2 rel2).
rrel1 =!= rrel2 ==> ~ (b1 === b2))
/// Before defining sub-buffer related API, we need to define the notion of "compatibility"
///
///
/// Sub-buffers can be taken at a different preorder than their parent buffers
/// But we need to ensure that the changes to the sub-buffer are compatible with the preorder
/// of the parent buffer, and vice versa.
(*
* The quantifiers are fiercely guarded, so if you are working directly with them,
* you may have to write additional asserts as triggers
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b: LowStar.Monotonic.Buffer.mbuffer a rrel rel ->
i: FStar.UInt32.t ->
len: FStar.UInt32.t{FStar.UInt32.v i + FStar.UInt32.v len <= LowStar.Monotonic.Buffer.length b} ->
sub_rel: LowStar.Monotonic.Buffer.srel a
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.UInt32.v",
"LowStar.Monotonic.Buffer.length",
"LowStar.Monotonic.Buffer.compatible_subseq_preorder",
"Prims.logical"
] | [] | false | false | false | false | true | let compatible_sub
(#a: Type0)
(#rrel #rel: srel a)
(b: mbuffer a rrel rel)
(i: U32.t)
(len: U32.t{U32.v i + U32.v len <= length b})
(sub_rel: srel a)
=
| compatible_subseq_preorder (length b) rel (U32.v i) (U32.v i + U32.v len) sub_rel | false |
|
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.length | val length (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel) : GTot nat | val length (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel) : GTot nat | let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b) | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 90,
"end_line": 206,
"start_col": 0,
"start_line": 206
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: LowStar.Monotonic.Buffer.mbuffer a rrel rel -> Prims.GTot Prims.nat | Prims.GTot | [
"sometrivial"
] | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.v",
"LowStar.Monotonic.Buffer.len",
"Prims.nat"
] | [] | false | false | false | false | false | let length (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel) : GTot nat =
| U32.v (len b) | false |
LowStar.Monotonic.Buffer.fsti | LowStar.Monotonic.Buffer.loc_union_idem_1 | val loc_union_idem_1 (s1 s2: loc)
: Lemma (loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))] | val loc_union_idem_1 (s1 s2: loc)
: Lemma (loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))] | let loc_union_idem_1
(s1 s2: loc)
: Lemma
(loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))]
= loc_union_assoc s1 s1 s2 | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 444,
"start_col": 0,
"start_line": 439
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul)
let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b
let length_null_2 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true)) (ensures (length b == 0))
[SMTPat (g_is_null b)]
= len_null a rrel rel;
null_unique b
/// For functional correctness, buffers are reflected at the proof
/// level using sequences, via ``as_seq b h``, which returns the
/// contents of a given buffer ``b`` in a given heap ``h``. If ``b`` is not
/// live in ``h``, then the result is unspecified.
(* TODO: why not return a lseq and remove length_as_seq lemma? *)
val as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot (Seq.seq a)
/// The contents of a buffer ``b`` has the same length as ``b`` itself.
val length_as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (Seq.length (as_seq h b) == length b)
[SMTPat (Seq.length (as_seq h b))]
/// ``get`` is an often-convenient shorthand to index the value of a
/// given buffer in a given heap, for proof purposes.
let get (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (p:mbuffer a rrel rel) (i:nat)
:Ghost a (requires (i < length p)) (ensures (fun _ -> True))
= Seq.index (as_seq h p) i
/// Injectivity in the first preorder
val mbuffer_injectivity_in_first_preorder (_:unit)
: Lemma (forall (a:Type0) (rrel1 rrel2 rel1 rel2:srel a)
(b1:mbuffer a rrel1 rel1)
(b2:mbuffer a rrel2 rel2).
rrel1 =!= rrel2 ==> ~ (b1 === b2))
/// Before defining sub-buffer related API, we need to define the notion of "compatibility"
///
///
/// Sub-buffers can be taken at a different preorder than their parent buffers
/// But we need to ensure that the changes to the sub-buffer are compatible with the preorder
/// of the parent buffer, and vice versa.
(*
* The quantifiers are fiercely guarded, so if you are working directly with them,
* you may have to write additional asserts as triggers
*)
[@@"opaque_to_smt"]
unfold let compatible_sub
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t{U32.v i + U32.v len <= length b}) (sub_rel:srel a)
= compatible_subseq_preorder (length b) rel (U32.v i) (U32.v i + U32.v len) sub_rel
/// ``gsub`` is the way to carve a sub-buffer out of a given
/// buffer. ``gsub b i len`` return the sub-buffer of ``b`` starting from
/// offset ``i`` within ``b``, and with length ``len``. Of course ``i`` and
/// ``len`` must fit within the length of ``b``.
///
/// Further the clients can attach a preorder with the subbuffer (sub_rel),
/// provided it is compatible
///
/// ``gsub`` is the ghost version, for proof purposes. Its stateful
/// counterpart is ``sub``, see below.
val mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Ghost (mbuffer a rrel sub_rel)
(requires (U32.v i + U32.v len <= length b))
(ensures (fun _ -> True))
// goffset
/// A buffer is live exactly at the same time as all of its sub-buffers.
val live_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b /\ compatible_sub b i len sub_rel))
(ensures (live h b <==> (live h (mgsub sub_rel b i len) /\ (exists h0 . {:pattern (live h0 b)} live h0 b))))
[SMTPatOr [
[SMTPat (live h (mgsub sub_rel b i len))];
[SMTPat (live h b); SMTPat (mgsub sub_rel b i len);]
]]
val gsub_is_null (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (g_is_null (mgsub sub_rel b i len) <==> g_is_null b))
[SMTPat (g_is_null (mgsub sub_rel b i len))]
/// The length of a sub-buffer is exactly the one provided at ``gsub``.
val len_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len':U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len' <= length b))
(ensures (len (mgsub sub_rel b i len') == len'))
[SMTPatOr [
[SMTPat (len (mgsub sub_rel b i len'))];
[SMTPat (length (mgsub sub_rel b i len'))];
]]
val frameOf_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (frameOf (mgsub sub_rel b i len) == frameOf b))
[SMTPat (frameOf (mgsub sub_rel b i len))]
val as_addr_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_addr (mgsub sub_rel b i len) == as_addr b))
[SMTPat (as_addr (mgsub sub_rel b i len))]
val mgsub_inj (#a:Type0) (#rrel #rel:srel a) (sub_rel1 sub_rel2:srel a)
(b1 b2:mbuffer a rrel rel)
(i1 i2:U32.t)
(len1 len2:U32.t)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b1 /\
U32.v i2 + U32.v len2 <= length b2 /\
mgsub sub_rel1 b1 i1 len1 === mgsub sub_rel2 b2 i2 len2))
(ensures (len1 == len2 /\ (b1 == b2 ==> i1 == i2) /\ ((i1 == i2 /\ length b1 == length b2) ==> b1 == b2)))
/// Nesting two ``gsub`` collapses into one ``gsub``, transitively.
val gsub_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i1:U32.t) (len1:U32.t) (sub_rel1:srel a)
(i2: U32.t) (len2: U32.t) (sub_rel2:srel a)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b /\
U32.v i2 + U32.v len2 <= U32.v len1))
(ensures (((compatible_sub b i1 len1 sub_rel1 /\ compatible_sub (mgsub sub_rel1 b i1 len1) i2 len2 sub_rel2) ==> compatible_sub b (U32.add i1 i2) len2 sub_rel2) /\
mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2 == mgsub sub_rel2 b (U32.add i1 i2) len2))
[SMTPat (mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2)]
/// A buffer ``b`` is equal to its "largest" sub-buffer, at index 0 and
/// length ``len b``.
val gsub_zero_length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (compatible_sub b 0ul (len b) rel /\ b == mgsub rel b 0ul (len b))
/// The contents of a sub-buffer is the corresponding slice of the
/// contents of its enclosing buffer.
val as_seq_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_seq h (mgsub sub_rel b i len) == Seq.slice (as_seq h b) (U32.v i) (U32.v i + U32.v len)))
[SMTPat (as_seq h (mgsub sub_rel b i len))]
/// Two live non-null buffers having the same region and address have
/// their elements of the same type.
val live_same_addresses_equal_types_and_preorders
(#a1 #a2: Type0)
(#rrel1 #rel1: srel a1)
(#rrel2 #rel2: srel a2)
(b1: mbuffer a1 rrel1 rel1)
(b2: mbuffer a2 rrel2 rel2)
(h: HS.mem)
: Lemma
((frameOf b1 == frameOf b2 /\ as_addr b1 == as_addr b2 /\ live h b1 /\ live h b2 /\ (~ (g_is_null b1 /\ g_is_null b2))) ==> (a1 == a2 /\ rrel1 == rrel2))
/// # The modifies clause
///
/// The modifies clause for regions, references and buffers.
/// ==========================================================
///
/// This module presents the modifies clause, a way to track the set
/// of memory locations modified by a stateful Low* (or even F*)
/// program. The basic principle of modifies clauses is that any
/// location that is disjoint from a set of memory locations modified
/// by an operation is preserved by that operation.
///
/// We start by specifying a monoid of sets of memory locations. From
/// a rough high-level view, ``loc`` is the type of sets of memory
/// locations, equipped with an identity element ``loc_none``,
/// representing the empty set, and an associative and commutative
/// operator, ``loc_union``, representing the union of two sets of
/// memory locations.
///
/// Moreover, ``loc_union`` is idempotent, which is useful to cut SMT
/// matching loops with ``modifies_trans`` and ``modifies_refl`` below.
val loc : Type0
val loc_none: loc
val loc_union
(s1 s2: loc)
: GTot loc
val loc_union_idem
(s: loc)
: Lemma
(loc_union s s == s)
[SMTPat (loc_union s s)]
val loc_union_comm
(s1 s2: loc)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
[SMTPat (loc_union s1 s2)]
val loc_union_assoc
(s1 s2 s3: loc)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.ModifiesGen",
"short_module": "MG"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s1: LowStar.Monotonic.Buffer.loc -> s2: LowStar.Monotonic.Buffer.loc
-> FStar.Pervasives.Lemma
(ensures
LowStar.Monotonic.Buffer.loc_union s1 (LowStar.Monotonic.Buffer.loc_union s1 s2) ==
LowStar.Monotonic.Buffer.loc_union s1 s2)
[SMTPat (LowStar.Monotonic.Buffer.loc_union s1 (LowStar.Monotonic.Buffer.loc_union s1 s2))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowStar.Monotonic.Buffer.loc",
"LowStar.Monotonic.Buffer.loc_union_assoc",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"LowStar.Monotonic.Buffer.loc_union",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | true | false | true | false | false | let loc_union_idem_1 (s1 s2: loc)
: Lemma (loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))] =
| loc_union_assoc s1 s1 s2 | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.