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
EverCrypt.AEAD.fst
EverCrypt.AEAD.decrypt_expand_aes128_gcm
val decrypt_expand_aes128_gcm: decrypt_expand_st true AES128_GCM
val decrypt_expand_aes128_gcm: decrypt_expand_st true AES128_GCM
let decrypt_expand_aes128_gcm : decrypt_expand_st true AES128_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then decrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len cipher cipher_len tag dst else UnsupportedAlgorithm else UnsupportedAlgorithm
{ "file_name": "providers/evercrypt/fst/EverCrypt.AEAD.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 657, "start_col": 0, "start_line": 644 }
module EverCrypt.AEAD module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open FStar.Int.Cast open Spec.Agile.AEAD open Spec.Cipher.Expansion open EverCrypt.CTR.Keys friend Spec.Agile.AEAD friend Spec.Cipher.Expansion friend EverCrypt.CTR.Keys #set-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0" /// Defining abstract predicates, invariants, footprint, etc. /// --------------------------------------------------------- let _: squash (inversion impl) = allow_inversion impl /// We now distinguish between an expanded key (as mandated by NIST spec) and a /// **concrete** expanded key, which may contain implementation-specific details /// and extra precomputations. In the rest of this module, we rely on concrete /// expanded keys, which are parameterized over an implementation, instead of /// regular expanded keys, which are parameterized over an algorithm. Helpers /// allow us to move from one notion to the other. let supported_alg_of_impl (i: impl): supported_alg = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM | Hacl_CHACHA20 -> CHACHA20_POLY1305 inline_for_extraction noextract let alg_of_vale_impl (i: vale_impl) = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM noeq type state_s a = | Ek: impl:impl -> kv:G.erased (kv a) -> ek:B.buffer UInt8.t -> // concrete expanded key state_s a let invert_state_s (a: alg): Lemma (requires True) (ensures (inversion (state_s a))) [ SMTPat (state_s a) ] = allow_inversion (state_s a) let freeable_s #a (Ek _ _ ek) = B.freeable ek let footprint_s #a (Ek _ _ ek) = B.loc_addr_of_buffer ek let invariant_s #a h (Ek i kv ek) = is_supported_alg a /\ a = supported_alg_of_impl i /\ B.live h ek /\ B.length ek >= concrete_xkey_length i /\ B.as_seq h (B.gsub ek 0ul (UInt32.uint_to_t (concrete_xkey_length i))) `S.equal` concrete_expand i (G.reveal kv) /\ config_pre a /\ ( match i with | Vale_AES128 | Vale_AES256 -> // Expanded key length + precomputed stuff + scratch space (AES-GCM specific) B.length ek = vale_xkey_length (cipher_alg_of_supported_alg a) + 176 | Hacl_CHACHA20 -> B.length ek = concrete_xkey_length i) let invariant_loc_in_footprint #a s m = () let frame_invariant #a l s h0 h1 = () /// Actual stateful API /// ------------------- let alg_of_state a s = let open LowStar.BufferOps in let Ek impl _ _ = !*s in match impl with | Hacl_CHACHA20 -> CHACHA20_POLY1305 | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM let as_kv #a (Ek _ kv _) = G.reveal kv #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" let create_in_chacha20_poly1305: create_in_st CHACHA20_POLY1305 = fun r dst k -> let h0 = ST.get () in let ek = B.malloc r 0uy 32ul in let p = B.malloc r (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; B.upd dst 0ul p; let h2 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h0 h2; Success #pop-options inline_for_extraction noextract let create_in_aes_gcm (i: vale_impl): create_in_st (alg_of_vale_impl i) = fun r dst k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in if EverCrypt.TargetConfig.hacl_can_compile_vale then ( let has_aesni = EverCrypt.AutoConfig2.has_aesni () in let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then ( let ek = B.malloc r 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.malloc r (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in let open LowStar.BufferOps in dst *= p; let h3 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h2 h3; Success ) else UnsupportedAlgorithm ) else UnsupportedAlgorithm let create_in_aes128_gcm: create_in_st AES128_GCM = create_in_aes_gcm Vale_AES128 let create_in_aes256_gcm: create_in_st AES256_GCM = create_in_aes_gcm Vale_AES256 let create_in #a r dst k = match a with | AES128_GCM -> create_in_aes128_gcm r dst k | AES256_GCM -> create_in_aes256_gcm r dst k | CHACHA20_POLY1305 -> create_in_chacha20_poly1305 r dst k | _ -> UnsupportedAlgorithm #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" inline_for_extraction noextract let alloca_chacha20_poly1305: alloca_st CHACHA20_POLY1305 = fun k -> let h0 = ST.get () in let ek = B.alloca 0uy 32ul in let p = B.alloca (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; let h3 = ST.get() in B.modifies_only_not_unused_in B.loc_none h0 h3; p #pop-options inline_for_extraction noextract let alloca_aes_gcm (i: vale_impl): alloca_st (alg_of_vale_impl i) = fun k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in let ek = B.alloca 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.alloca (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in p inline_for_extraction noextract let alloca_aes128_gcm: alloca_st AES128_GCM = alloca_aes_gcm Vale_AES128 inline_for_extraction noextract let alloca_aes256_gcm: alloca_st AES256_GCM = alloca_aes_gcm Vale_AES256 let alloca #a k = match a with | AES128_GCM -> alloca_aes128_gcm k | AES256_GCM -> alloca_aes256_gcm k | CHACHA20_POLY1305 -> alloca_chacha20_poly1305 k inline_for_extraction noextract let aes_gcm_encrypt (i: vale_impl): Vale.Wrapper.X64.GCMencryptOpt.encrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMencryptOpt256.gcm256_encrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let encrypt_aes_gcm (i: vale_impl): encrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if B.is_null s then InvalidKey else let a = alg_of_vale_impl i in // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let h0 = get() in aes_gcm_encrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) plain (uint32_to_uint64 plain_len) ad (uint32_to_uint64 ad_len) tmp_iv cipher tag keys_b hkeys_b scratch_b; let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // and tag. It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 plain) in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in Seq.equal (B.as_seq h1 cipher) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat) /\ Seq.equal (B.as_seq h1 tag) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat)); pop_frame(); Success let encrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES128_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES256_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt #a s iv iv_len ad ad_len plain plain_len cipher tag = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> encrypt_aes128_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Vale_AES256 -> encrypt_aes256_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Hacl_CHACHA20 -> // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin // Length restrictions assert_norm (pow2 31 + pow2 32 / 64 <= pow2 32 - 1); EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; Success end inline_for_extraction noextract let encrypt_expand_aes_gcm (i: vale_impl): encrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = encrypt_aes_gcm i s iv iv_len ad ad_len plain plain_len cipher tag in assert(r == Success); pop_frame (); Success let encrypt_expand_aes128_gcm_no_check : encrypt_expand_st false AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes256_gcm_no_check : encrypt_expand_st false AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes128_gcm : encrypt_expand_st true AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_aes256_gcm : encrypt_expand_st true AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_chacha20_poly1305 : encrypt_expand_st false CHACHA20_POLY1305 = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s CHACHA20_POLY1305) = alloca k in let open LowStar.BufferOps in let Ek i kv ek = !*s in EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; pop_frame (); Success let encrypt_expand #a k iv iv_len ad ad_len plain plain_len cipher tag = match a with | AES128_GCM -> encrypt_expand_aes128_gcm k iv iv_len ad ad_len plain plain_len cipher tag | AES256_GCM -> encrypt_expand_aes256_gcm k iv iv_len ad ad_len plain plain_len cipher tag | CHACHA20_POLY1305 -> encrypt_expand_chacha20_poly1305 k iv iv_len ad ad_len plain plain_len cipher tag inline_for_extraction noextract let aes_gcm_decrypt (i: vale_impl): Vale.Wrapper.X64.GCMdecryptOpt.decrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMdecryptOpt.gcm128_decrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMdecryptOpt256.gcm256_decrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let decrypt_aes_gcm (i: vale_impl): decrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let a = alg_of_vale_impl i in let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let r = aes_gcm_decrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) cipher (uint32_to_uint64 cipher_len) ad (uint32_to_uint64 ad_len) tmp_iv dst tag keys_b hkeys_b scratch_b in let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let cipher_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 cipher) in let tag_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 tag) in let plain_nat, success = Vale.AES.GCM_s.gcm_decrypt_LE (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat in Seq.equal (B.as_seq h1 dst) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 plain_nat) /\ (UInt64.v r = 0) == success); assert ( let kv = G.reveal kv in let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in Seq.equal (Seq.slice cipher_tag (S.length cipher_tag - tag_length a) (S.length cipher_tag)) (B.as_seq h0 tag) /\ Seq.equal (Seq.slice cipher_tag 0 (S.length cipher_tag - tag_length a)) (B.as_seq h0 cipher)); pop_frame(); if r = 0uL then Success else AuthenticationFailure let decrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): decrypt_st AES128_GCM = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len cipher cipher_len tag dst else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let decrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): decrypt_st AES256_GCM = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len cipher cipher_len tag dst else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let decrypt_chacha20_poly1305 : decrypt_st CHACHA20_POLY1305 = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin let open LowStar.BufferOps in let Ek i kv ek = !*s in [@ inline_let ] let bound = pow2 32 - 1 - 16 in assert (v cipher_len <= bound); assert_norm (bound + 16 <= pow2 32 - 1); assert_norm (pow2 31 + bound / 64 <= pow2 32 - 1); let h0 = ST.get () in let r = EverCrypt.Chacha20Poly1305.aead_decrypt ek iv ad_len ad cipher_len dst cipher tag in assert ( let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in let tag_s = S.slice cipher_tag (S.length cipher_tag - tag_length CHACHA20_POLY1305) (S.length cipher_tag) in let cipher_s = S.slice cipher_tag 0 (S.length cipher_tag - tag_length CHACHA20_POLY1305) in S.equal cipher_s (B.as_seq h0 cipher) /\ S.equal tag_s (B.as_seq h0 tag)); if r = 0ul then Success else AuthenticationFailure end let decrypt #a s iv iv_len ad ad_len cipher cipher_len tag dst = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> decrypt_aes128_gcm () s iv iv_len ad ad_len cipher cipher_len tag dst | Vale_AES256 -> decrypt_aes256_gcm () s iv iv_len ad ad_len cipher cipher_len tag dst | Hacl_CHACHA20 -> decrypt_chacha20_poly1305 s iv iv_len ad ad_len cipher cipher_len tag dst inline_for_extraction noextract let decrypt_expand_aes_gcm (i: vale_impl): decrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = decrypt_aes_gcm i s iv iv_len ad ad_len cipher cipher_len tag dst in pop_frame (); r let decrypt_expand_aes128_gcm_no_check : decrypt_expand_st false AES128_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len cipher cipher_len tag dst else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let decrypt_expand_aes256_gcm_no_check : decrypt_expand_st false AES256_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len cipher cipher_len tag dst else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale"
{ "checked_file": "/", "dependencies": [ "Vale.Wrapper.X64.GCMencryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMencryptOpt.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt.fsti.checked", "Vale.Wrapper.X64.GCM_IV.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Agile.AEAD.fst.checked", "Spec.Agile.AEAD.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.Chacha20Poly1305.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AEAD.fst" }
[ { "abbrev": false, "full_module": "EverCrypt.CTR.Keys", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher.Expansion", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "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": 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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AEAD.decrypt_expand_st true Spec.Agile.AEAD.AES128_GCM
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.buffer", "EverCrypt.CTR.Keys.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "Spec.Agile.AEAD.AES128_GCM", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "FStar.Integers.op_Greater", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.cipher_p", "Spec.Agile.AEAD.tag_length", "Prims.nat", "EverCrypt.TargetConfig.hacl_can_compile_vale", "Prims.op_AmpAmp", "EverCrypt.AEAD.decrypt_expand_aes_gcm", "Spec.Cipher.Expansion.Vale_AES128", "EverCrypt.Error.error_code", "Prims.bool", "EverCrypt.Error.UnsupportedAlgorithm", "EverCrypt.AutoConfig2.has_aesni", "EverCrypt.AutoConfig2.has_movbe", "EverCrypt.AutoConfig2.has_sse", "EverCrypt.AutoConfig2.has_avx", "EverCrypt.AutoConfig2.has_pclmulqdq", "EverCrypt.AEAD.decrypt_expand_st" ]
[]
false
false
false
false
false
let decrypt_expand_aes128_gcm:decrypt_expand_st true AES128_GCM =
fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx () in let has_sse = EverCrypt.AutoConfig2.has_sse () in let has_movbe = EverCrypt.AutoConfig2.has_movbe () in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then decrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len cipher cipher_len tag dst else UnsupportedAlgorithm else UnsupportedAlgorithm
false
EverCrypt.AEAD.fst
EverCrypt.AEAD.decrypt_expand_aes256_gcm
val decrypt_expand_aes256_gcm: decrypt_expand_st true AES256_GCM
val decrypt_expand_aes256_gcm: decrypt_expand_st true AES256_GCM
let decrypt_expand_aes256_gcm : decrypt_expand_st true AES256_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then decrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len cipher cipher_len tag dst else UnsupportedAlgorithm else UnsupportedAlgorithm
{ "file_name": "providers/evercrypt/fst/EverCrypt.AEAD.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 672, "start_col": 0, "start_line": 659 }
module EverCrypt.AEAD module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open FStar.Int.Cast open Spec.Agile.AEAD open Spec.Cipher.Expansion open EverCrypt.CTR.Keys friend Spec.Agile.AEAD friend Spec.Cipher.Expansion friend EverCrypt.CTR.Keys #set-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0" /// Defining abstract predicates, invariants, footprint, etc. /// --------------------------------------------------------- let _: squash (inversion impl) = allow_inversion impl /// We now distinguish between an expanded key (as mandated by NIST spec) and a /// **concrete** expanded key, which may contain implementation-specific details /// and extra precomputations. In the rest of this module, we rely on concrete /// expanded keys, which are parameterized over an implementation, instead of /// regular expanded keys, which are parameterized over an algorithm. Helpers /// allow us to move from one notion to the other. let supported_alg_of_impl (i: impl): supported_alg = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM | Hacl_CHACHA20 -> CHACHA20_POLY1305 inline_for_extraction noextract let alg_of_vale_impl (i: vale_impl) = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM noeq type state_s a = | Ek: impl:impl -> kv:G.erased (kv a) -> ek:B.buffer UInt8.t -> // concrete expanded key state_s a let invert_state_s (a: alg): Lemma (requires True) (ensures (inversion (state_s a))) [ SMTPat (state_s a) ] = allow_inversion (state_s a) let freeable_s #a (Ek _ _ ek) = B.freeable ek let footprint_s #a (Ek _ _ ek) = B.loc_addr_of_buffer ek let invariant_s #a h (Ek i kv ek) = is_supported_alg a /\ a = supported_alg_of_impl i /\ B.live h ek /\ B.length ek >= concrete_xkey_length i /\ B.as_seq h (B.gsub ek 0ul (UInt32.uint_to_t (concrete_xkey_length i))) `S.equal` concrete_expand i (G.reveal kv) /\ config_pre a /\ ( match i with | Vale_AES128 | Vale_AES256 -> // Expanded key length + precomputed stuff + scratch space (AES-GCM specific) B.length ek = vale_xkey_length (cipher_alg_of_supported_alg a) + 176 | Hacl_CHACHA20 -> B.length ek = concrete_xkey_length i) let invariant_loc_in_footprint #a s m = () let frame_invariant #a l s h0 h1 = () /// Actual stateful API /// ------------------- let alg_of_state a s = let open LowStar.BufferOps in let Ek impl _ _ = !*s in match impl with | Hacl_CHACHA20 -> CHACHA20_POLY1305 | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM let as_kv #a (Ek _ kv _) = G.reveal kv #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" let create_in_chacha20_poly1305: create_in_st CHACHA20_POLY1305 = fun r dst k -> let h0 = ST.get () in let ek = B.malloc r 0uy 32ul in let p = B.malloc r (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; B.upd dst 0ul p; let h2 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h0 h2; Success #pop-options inline_for_extraction noextract let create_in_aes_gcm (i: vale_impl): create_in_st (alg_of_vale_impl i) = fun r dst k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in if EverCrypt.TargetConfig.hacl_can_compile_vale then ( let has_aesni = EverCrypt.AutoConfig2.has_aesni () in let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then ( let ek = B.malloc r 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.malloc r (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in let open LowStar.BufferOps in dst *= p; let h3 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h2 h3; Success ) else UnsupportedAlgorithm ) else UnsupportedAlgorithm let create_in_aes128_gcm: create_in_st AES128_GCM = create_in_aes_gcm Vale_AES128 let create_in_aes256_gcm: create_in_st AES256_GCM = create_in_aes_gcm Vale_AES256 let create_in #a r dst k = match a with | AES128_GCM -> create_in_aes128_gcm r dst k | AES256_GCM -> create_in_aes256_gcm r dst k | CHACHA20_POLY1305 -> create_in_chacha20_poly1305 r dst k | _ -> UnsupportedAlgorithm #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" inline_for_extraction noextract let alloca_chacha20_poly1305: alloca_st CHACHA20_POLY1305 = fun k -> let h0 = ST.get () in let ek = B.alloca 0uy 32ul in let p = B.alloca (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; let h3 = ST.get() in B.modifies_only_not_unused_in B.loc_none h0 h3; p #pop-options inline_for_extraction noextract let alloca_aes_gcm (i: vale_impl): alloca_st (alg_of_vale_impl i) = fun k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in let ek = B.alloca 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.alloca (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in p inline_for_extraction noextract let alloca_aes128_gcm: alloca_st AES128_GCM = alloca_aes_gcm Vale_AES128 inline_for_extraction noextract let alloca_aes256_gcm: alloca_st AES256_GCM = alloca_aes_gcm Vale_AES256 let alloca #a k = match a with | AES128_GCM -> alloca_aes128_gcm k | AES256_GCM -> alloca_aes256_gcm k | CHACHA20_POLY1305 -> alloca_chacha20_poly1305 k inline_for_extraction noextract let aes_gcm_encrypt (i: vale_impl): Vale.Wrapper.X64.GCMencryptOpt.encrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMencryptOpt256.gcm256_encrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let encrypt_aes_gcm (i: vale_impl): encrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if B.is_null s then InvalidKey else let a = alg_of_vale_impl i in // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let h0 = get() in aes_gcm_encrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) plain (uint32_to_uint64 plain_len) ad (uint32_to_uint64 ad_len) tmp_iv cipher tag keys_b hkeys_b scratch_b; let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // and tag. It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 plain) in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in Seq.equal (B.as_seq h1 cipher) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat) /\ Seq.equal (B.as_seq h1 tag) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat)); pop_frame(); Success let encrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES128_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES256_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt #a s iv iv_len ad ad_len plain plain_len cipher tag = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> encrypt_aes128_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Vale_AES256 -> encrypt_aes256_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Hacl_CHACHA20 -> // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin // Length restrictions assert_norm (pow2 31 + pow2 32 / 64 <= pow2 32 - 1); EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; Success end inline_for_extraction noextract let encrypt_expand_aes_gcm (i: vale_impl): encrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = encrypt_aes_gcm i s iv iv_len ad ad_len plain plain_len cipher tag in assert(r == Success); pop_frame (); Success let encrypt_expand_aes128_gcm_no_check : encrypt_expand_st false AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes256_gcm_no_check : encrypt_expand_st false AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes128_gcm : encrypt_expand_st true AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_aes256_gcm : encrypt_expand_st true AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_chacha20_poly1305 : encrypt_expand_st false CHACHA20_POLY1305 = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s CHACHA20_POLY1305) = alloca k in let open LowStar.BufferOps in let Ek i kv ek = !*s in EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; pop_frame (); Success let encrypt_expand #a k iv iv_len ad ad_len plain plain_len cipher tag = match a with | AES128_GCM -> encrypt_expand_aes128_gcm k iv iv_len ad ad_len plain plain_len cipher tag | AES256_GCM -> encrypt_expand_aes256_gcm k iv iv_len ad ad_len plain plain_len cipher tag | CHACHA20_POLY1305 -> encrypt_expand_chacha20_poly1305 k iv iv_len ad ad_len plain plain_len cipher tag inline_for_extraction noextract let aes_gcm_decrypt (i: vale_impl): Vale.Wrapper.X64.GCMdecryptOpt.decrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMdecryptOpt.gcm128_decrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMdecryptOpt256.gcm256_decrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let decrypt_aes_gcm (i: vale_impl): decrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let a = alg_of_vale_impl i in let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let r = aes_gcm_decrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) cipher (uint32_to_uint64 cipher_len) ad (uint32_to_uint64 ad_len) tmp_iv dst tag keys_b hkeys_b scratch_b in let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let cipher_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 cipher) in let tag_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 tag) in let plain_nat, success = Vale.AES.GCM_s.gcm_decrypt_LE (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat in Seq.equal (B.as_seq h1 dst) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 plain_nat) /\ (UInt64.v r = 0) == success); assert ( let kv = G.reveal kv in let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in Seq.equal (Seq.slice cipher_tag (S.length cipher_tag - tag_length a) (S.length cipher_tag)) (B.as_seq h0 tag) /\ Seq.equal (Seq.slice cipher_tag 0 (S.length cipher_tag - tag_length a)) (B.as_seq h0 cipher)); pop_frame(); if r = 0uL then Success else AuthenticationFailure let decrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): decrypt_st AES128_GCM = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len cipher cipher_len tag dst else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let decrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): decrypt_st AES256_GCM = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len cipher cipher_len tag dst else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let decrypt_chacha20_poly1305 : decrypt_st CHACHA20_POLY1305 = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin let open LowStar.BufferOps in let Ek i kv ek = !*s in [@ inline_let ] let bound = pow2 32 - 1 - 16 in assert (v cipher_len <= bound); assert_norm (bound + 16 <= pow2 32 - 1); assert_norm (pow2 31 + bound / 64 <= pow2 32 - 1); let h0 = ST.get () in let r = EverCrypt.Chacha20Poly1305.aead_decrypt ek iv ad_len ad cipher_len dst cipher tag in assert ( let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in let tag_s = S.slice cipher_tag (S.length cipher_tag - tag_length CHACHA20_POLY1305) (S.length cipher_tag) in let cipher_s = S.slice cipher_tag 0 (S.length cipher_tag - tag_length CHACHA20_POLY1305) in S.equal cipher_s (B.as_seq h0 cipher) /\ S.equal tag_s (B.as_seq h0 tag)); if r = 0ul then Success else AuthenticationFailure end let decrypt #a s iv iv_len ad ad_len cipher cipher_len tag dst = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> decrypt_aes128_gcm () s iv iv_len ad ad_len cipher cipher_len tag dst | Vale_AES256 -> decrypt_aes256_gcm () s iv iv_len ad ad_len cipher cipher_len tag dst | Hacl_CHACHA20 -> decrypt_chacha20_poly1305 s iv iv_len ad ad_len cipher cipher_len tag dst inline_for_extraction noextract let decrypt_expand_aes_gcm (i: vale_impl): decrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = decrypt_aes_gcm i s iv iv_len ad ad_len cipher cipher_len tag dst in pop_frame (); r let decrypt_expand_aes128_gcm_no_check : decrypt_expand_st false AES128_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len cipher cipher_len tag dst else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let decrypt_expand_aes256_gcm_no_check : decrypt_expand_st false AES256_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len cipher cipher_len tag dst else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let decrypt_expand_aes128_gcm : decrypt_expand_st true AES128_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then decrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len cipher cipher_len tag dst else UnsupportedAlgorithm else UnsupportedAlgorithm
{ "checked_file": "/", "dependencies": [ "Vale.Wrapper.X64.GCMencryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMencryptOpt.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt.fsti.checked", "Vale.Wrapper.X64.GCM_IV.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Agile.AEAD.fst.checked", "Spec.Agile.AEAD.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.Chacha20Poly1305.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AEAD.fst" }
[ { "abbrev": false, "full_module": "EverCrypt.CTR.Keys", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher.Expansion", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "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": 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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AEAD.decrypt_expand_st true Spec.Agile.AEAD.AES256_GCM
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.buffer", "EverCrypt.CTR.Keys.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "Spec.Agile.AEAD.AES256_GCM", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "FStar.Integers.op_Greater", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.cipher_p", "Spec.Agile.AEAD.tag_length", "Prims.nat", "EverCrypt.TargetConfig.hacl_can_compile_vale", "Prims.op_AmpAmp", "EverCrypt.AEAD.decrypt_expand_aes_gcm", "Spec.Cipher.Expansion.Vale_AES256", "EverCrypt.Error.error_code", "Prims.bool", "EverCrypt.Error.UnsupportedAlgorithm", "EverCrypt.AutoConfig2.has_aesni", "EverCrypt.AutoConfig2.has_movbe", "EverCrypt.AutoConfig2.has_sse", "EverCrypt.AutoConfig2.has_avx", "EverCrypt.AutoConfig2.has_pclmulqdq", "EverCrypt.AEAD.decrypt_expand_st" ]
[]
false
false
false
false
false
let decrypt_expand_aes256_gcm:decrypt_expand_st true AES256_GCM =
fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx () in let has_sse = EverCrypt.AutoConfig2.has_sse () in let has_movbe = EverCrypt.AutoConfig2.has_movbe () in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then decrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len cipher cipher_len tag dst else UnsupportedAlgorithm else UnsupportedAlgorithm
false
Hacl.SHA2.Vec256.fst
Hacl.SHA2.Vec256.sha224_8
val sha224_8 (dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 : lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3 input4 input5 input6 input7 : lbuffer uint8 input_len) : Stack unit (requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\ live8 h0 input0 input1 input2 input3 input4 input5 input6 input7 /\ live8 h0 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 /\ internally_disjoint8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7) (ensures fun h0 _ h1 -> modifies (loc dst0 |+| (loc dst1 |+| (loc dst2 |+| (loc dst3 |+| (loc dst4 |+| (loc dst5 |+| (loc dst6 |+| loc dst7))))))) h0 h1 /\ as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\ as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\ as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\ as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3) /\ as_seq h1 dst4 == Spec.hash SHA2_224 (as_seq h0 input4) /\ as_seq h1 dst5 == Spec.hash SHA2_224 (as_seq h0 input5) /\ as_seq h1 dst6 == Spec.hash SHA2_224 (as_seq h0 input6) /\ as_seq h1 dst7 == Spec.hash SHA2_224 (as_seq h0 input7))
val sha224_8 (dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 : lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3 input4 input5 input6 input7 : lbuffer uint8 input_len) : Stack unit (requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\ live8 h0 input0 input1 input2 input3 input4 input5 input6 input7 /\ live8 h0 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 /\ internally_disjoint8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7) (ensures fun h0 _ h1 -> modifies (loc dst0 |+| (loc dst1 |+| (loc dst2 |+| (loc dst3 |+| (loc dst4 |+| (loc dst5 |+| (loc dst6 |+| loc dst7))))))) h0 h1 /\ as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\ as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\ as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\ as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3) /\ as_seq h1 dst4 == Spec.hash SHA2_224 (as_seq h0 input4) /\ as_seq h1 dst5 == Spec.hash SHA2_224 (as_seq h0 input5) /\ as_seq h1 dst6 == Spec.hash SHA2_224 (as_seq h0 input6) /\ as_seq h1 dst7 == Spec.hash SHA2_224 (as_seq h0 input7))
let sha224_8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 input_len input0 input1 input2 input3 input4 input5 input6 input7 = let ib = ntup8 (input0,(input1,(input2,(input3,(input4,(input5,(input6,input7))))))) in let rb = ntup8 (dst0,(dst1,(dst2,(dst3,(dst4,(dst5,(dst6,dst7))))))) in let h0 = ST.get() in assert (live_multi h0 ib); assert (live_multi h0 rb); assert (internally_disjoint rb); loc_multi8 rb; hash #SHA2_224 #M256 sha224_init8 sha224_update_nblocks8 sha224_update_last8 sha224_finish8 rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M256 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0); assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1); assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2); assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3); assert ((as_seq_multi h1 rb).(|4|) == as_seq h1 dst4); assert ((as_seq_multi h1 rb).(|5|) == as_seq h1 dst5); assert ((as_seq_multi h1 rb).(|6|) == as_seq h1 dst6); assert ((as_seq_multi h1 rb).(|7|) == as_seq h1 dst7)
{ "file_name": "code/sha2-mb/Hacl.SHA2.Vec256.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 66, "start_col": 0, "start_line": 48 }
module Hacl.SHA2.Vec256 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.MultiBuffer open Spec.Hash.Definitions open Hacl.Spec.SHA2.Vec open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST module Spec = Spec.Agile.Hash module SpecVec = Hacl.Spec.SHA2.Vec #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] private let sha224_init8 = init #SHA2_224 #M256 [@CInline] private let sha224_update8 = update #SHA2_224 #M256 [@CInline] private let sha224_update_nblocks8 = update_nblocks #SHA2_224 #M256 sha224_update8 [@CInline] private let sha224_update_last8 = update_last #SHA2_224 #M256 sha224_update8 [@CInline] private let sha224_finish8 = finish #SHA2_224 #M256 val sha224_8 (dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 : lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3 input4 input5 input6 input7 : lbuffer uint8 input_len) : Stack unit (requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\ live8 h0 input0 input1 input2 input3 input4 input5 input6 input7 /\ live8 h0 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 /\ internally_disjoint8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7) (ensures fun h0 _ h1 -> modifies (loc dst0 |+| (loc dst1 |+| (loc dst2 |+| (loc dst3 |+| (loc dst4 |+| (loc dst5 |+| (loc dst6 |+| loc dst7))))))) h0 h1 /\ as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\ as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\ as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\ as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3) /\ as_seq h1 dst4 == Spec.hash SHA2_224 (as_seq h0 input4) /\ as_seq h1 dst5 == Spec.hash SHA2_224 (as_seq h0 input5) /\ as_seq h1 dst6 == Spec.hash SHA2_224 (as_seq h0 input6) /\ as_seq h1 dst7 == Spec.hash SHA2_224 (as_seq h0 input7))
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Vec256.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
dst0: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul -> dst1: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul -> dst2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul -> dst3: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul -> dst4: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul -> dst5: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul -> dst6: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul -> dst7: Lib.Buffer.lbuffer Lib.IntTypes.uint8 28ul -> input_len: Lib.IntTypes.size_t -> input0: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input1: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input3: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input4: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input5: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input6: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input7: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Hash.Definitions.hash_len", "Spec.Hash.Definitions.SHA2_224", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.M256", "Lib.MultiBuffer.as_seq_multi", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.unit", "Hacl.Spec.SHA2.Equiv.hash_agile_lemma", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.SHA2.Generic.hash", "Hacl.SHA2.Vec256.sha224_init8", "Hacl.SHA2.Vec256.sha224_update_nblocks8", "Hacl.SHA2.Vec256.sha224_update_last8", "Hacl.SHA2.Vec256.sha224_finish8", "Lib.MultiBuffer.loc_multi8", "Lib.MultiBuffer.internally_disjoint", "Lib.MultiBuffer.live_multi", "Lib.NTuple.ntuple", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.NTuple.ntup8", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2" ]
[]
false
true
false
false
false
let sha224_8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 input_len input0 input1 input2 input3 input4 input5 input6 input7 =
let ib = ntup8 (input0, (input1, (input2, (input3, (input4, (input5, (input6, input7))))))) in let rb = ntup8 (dst0, (dst1, (dst2, (dst3, (dst4, (dst5, (dst6, dst7))))))) in let h0 = ST.get () in assert (live_multi h0 ib); assert (live_multi h0 rb); assert (internally_disjoint rb); loc_multi8 rb; hash #SHA2_224 #M256 sha224_init8 sha224_update_nblocks8 sha224_update_last8 sha224_finish8 rb input_len ib; let h1 = ST.get () in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M256 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 dst0); assert ((as_seq_multi h1 rb).(| 1 |) == as_seq h1 dst1); assert ((as_seq_multi h1 rb).(| 2 |) == as_seq h1 dst2); assert ((as_seq_multi h1 rb).(| 3 |) == as_seq h1 dst3); assert ((as_seq_multi h1 rb).(| 4 |) == as_seq h1 dst4); assert ((as_seq_multi h1 rb).(| 5 |) == as_seq h1 dst5); assert ((as_seq_multi h1 rb).(| 6 |) == as_seq h1 dst6); assert ((as_seq_multi h1 rb).(| 7 |) == as_seq h1 dst7)
false
Steel.PCMReference.fst
Steel.PCMReference.witness
val witness (#inames: _) (#a:Type) (#pcm:pcm a) (r:erased (ref a pcm)) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) : SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v)
val witness (#inames: _) (#a:Type) (#pcm:pcm a) (r:erased (ref a pcm)) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) : SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v)
let witness r fact v s = let w = witness' r fact v s in w
{ "file_name": "lib/steel/Steel.PCMReference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 93, "start_col": 0, "start_line": 91 }
(* Copyright 2020 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 Steel.PCMReference module Mem = Steel.Memory let read r v0 = let v = as_action (sel_action FStar.Set.empty r v0) in v let write r v0 v1 = as_action (upd_action FStar.Set.empty r v0 v1) val alloc' (#a:Type) (#pcm:pcm a) (x:a) : Steel (ref a pcm) (to_vprop Mem.emp) (fun r -> pts_to r x) (requires fun _ -> compatible pcm x x /\ pcm.refine x) (ensures fun _ _ _ -> True) let alloc' x = as_action (alloc_action FStar.Set.empty x) let alloc #_ #pcm x = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); compatible_refl pcm x; alloc' x let free r x = as_action (free_action FStar.Set.empty r x) val split' (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v0:erased a) (v1:erased a{composable p v0 v1}) : SteelGhostT unit inames (pts_to r (op p v0 v1)) (fun _ -> to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) let split' #inames #a #p r v0 v1 = as_atomic_action_ghost (split_action inames r v0 v1) let split #_ #a #p r v v0 v1 = let _:squash (composable p v0 v1) = () in rewrite_slprop (pts_to r v) (pts_to r (op p v0 v1)) (fun _ -> ()); split' r v0 v1; rewrite_slprop (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (pts_to r v0 `star` pts_to r v1) (fun _ -> ()) val gather' (#inames: _) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:erased a) (v1:erased a) : SteelGhostT (_:unit{composable p v0 v1}) inames (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (fun _ -> pts_to r (op p v0 v1)) let gather' #inames r v0 v1 = as_atomic_action_ghost (gather_action inames r v0 v1) let gather r v0 v1 = rewrite_slprop (pts_to r v0 `star` pts_to r v1) (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (fun _ -> ()); gather' r v0 v1 val witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:erased (ref a pcm)) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) : SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> to_vprop Mem.(pts_to r v)) let witness' #inames r fact v _ = as_atomic_unobservable_action (Steel.Memory.witness inames r fact v ())
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked" ], "interface_file": true, "source_file": "Steel.PCMReference.fst" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
r: FStar.Ghost.erased (Steel.Memory.ref a pcm) -> fact: Steel.Memory.stable_property pcm -> v: FStar.Ghost.erased a -> s: Steel.PCMReference.fact_valid_compat fact v -> Steel.Effect.Atomic.SteelAtomicUT (Steel.Memory.witnessed (FStar.Ghost.reveal r) fact)
Steel.Effect.Atomic.SteelAtomicUT
[]
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "FStar.Ghost.erased", "Steel.Memory.ref", "Steel.Memory.stable_property", "Steel.PCMReference.fact_valid_compat", "Steel.Memory.witnessed", "FStar.Ghost.reveal", "Steel.PCMReference.witness'" ]
[]
false
true
false
false
false
let witness r fact v s =
let w = witness' r fact v s in w
false
EngineTypes.fsti
EngineTypes.cdi_t
val cdi_t : Type0
let cdi_t = V.lvec U8.t (US.v (digest_len dice_hash_alg))
{ "file_name": "share/steel/examples/pulse/dice/engine/EngineTypes.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 57, "end_line": 31, "start_col": 0, "start_line": 31 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EngineTypes open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module V = Pulse.Lib.Vec module US = FStar.SizeT module U8 = FStar.UInt8 open HACL val uds_is_enabled : vprop val uds_len : hashable_len type dice_return_code = | DICE_SUCCESS | DICE_ERROR
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Vec.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "prims.fst.checked", "HACL.fst.checked", "FStar.UInt8.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EngineTypes.fsti" }
[ { "abbrev": false, "full_module": "HACL", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Pulse.Lib.Vec", "short_module": "V" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Pulse.Lib.Vec.lvec", "FStar.UInt8.t", "FStar.SizeT.v", "HACL.digest_len", "HACL.dice_hash_alg" ]
[]
false
false
false
true
true
let cdi_t =
V.lvec U8.t (US.v (digest_len dice_hash_alg))
false
Hacl.SHA2.Vec256.fst
Hacl.SHA2.Vec256.sha256_8
val sha256_8 (dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 : lbuffer uint8 32ul) (input_len:size_t) (input0 input1 input2 input3 input4 input5 input6 input7 : lbuffer uint8 input_len) : Stack unit (requires fun h0 -> v input_len `less_than_max_input_length` SHA2_256 /\ live8 h0 input0 input1 input2 input3 input4 input5 input6 input7 /\ live8 h0 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 /\ internally_disjoint8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7) (ensures fun h0 _ h1 -> modifies (loc dst0 |+| (loc dst1 |+| (loc dst2 |+| (loc dst3 |+| (loc dst4 |+| (loc dst5 |+| (loc dst6 |+| loc dst7))))))) h0 h1 /\ as_seq h1 dst0 == Spec.hash SHA2_256 (as_seq h0 input0) /\ as_seq h1 dst1 == Spec.hash SHA2_256 (as_seq h0 input1) /\ as_seq h1 dst2 == Spec.hash SHA2_256 (as_seq h0 input2) /\ as_seq h1 dst3 == Spec.hash SHA2_256 (as_seq h0 input3) /\ as_seq h1 dst4 == Spec.hash SHA2_256 (as_seq h0 input4) /\ as_seq h1 dst5 == Spec.hash SHA2_256 (as_seq h0 input5) /\ as_seq h1 dst6 == Spec.hash SHA2_256 (as_seq h0 input6) /\ as_seq h1 dst7 == Spec.hash SHA2_256 (as_seq h0 input7))
val sha256_8 (dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 : lbuffer uint8 32ul) (input_len:size_t) (input0 input1 input2 input3 input4 input5 input6 input7 : lbuffer uint8 input_len) : Stack unit (requires fun h0 -> v input_len `less_than_max_input_length` SHA2_256 /\ live8 h0 input0 input1 input2 input3 input4 input5 input6 input7 /\ live8 h0 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 /\ internally_disjoint8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7) (ensures fun h0 _ h1 -> modifies (loc dst0 |+| (loc dst1 |+| (loc dst2 |+| (loc dst3 |+| (loc dst4 |+| (loc dst5 |+| (loc dst6 |+| loc dst7))))))) h0 h1 /\ as_seq h1 dst0 == Spec.hash SHA2_256 (as_seq h0 input0) /\ as_seq h1 dst1 == Spec.hash SHA2_256 (as_seq h0 input1) /\ as_seq h1 dst2 == Spec.hash SHA2_256 (as_seq h0 input2) /\ as_seq h1 dst3 == Spec.hash SHA2_256 (as_seq h0 input3) /\ as_seq h1 dst4 == Spec.hash SHA2_256 (as_seq h0 input4) /\ as_seq h1 dst5 == Spec.hash SHA2_256 (as_seq h0 input5) /\ as_seq h1 dst6 == Spec.hash SHA2_256 (as_seq h0 input6) /\ as_seq h1 dst7 == Spec.hash SHA2_256 (as_seq h0 input7))
let sha256_8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 input_len input0 input1 input2 input3 input4 input5 input6 input7 = let ib = ntup8 (input0,(input1,(input2,(input3,(input4,(input5,(input6,input7))))))) in let rb = ntup8 (dst0,(dst1,(dst2,(dst3,(dst4,(dst5,(dst6,dst7))))))) in let h0 = ST.get() in assert (live_multi h0 ib); assert (live_multi h0 rb); assert (internally_disjoint rb); loc_multi8 rb; hash #SHA2_256 #M256 sha256_init8 sha256_update_nblocks8 sha256_update_last8 sha256_finish8 rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M256 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0); assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1); assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2); assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3); assert ((as_seq_multi h1 rb).(|4|) == as_seq h1 dst4); assert ((as_seq_multi h1 rb).(|5|) == as_seq h1 dst5); assert ((as_seq_multi h1 rb).(|6|) == as_seq h1 dst6); assert ((as_seq_multi h1 rb).(|7|) == as_seq h1 dst7)
{ "file_name": "code/sha2-mb/Hacl.SHA2.Vec256.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 114, "start_col": 0, "start_line": 96 }
module Hacl.SHA2.Vec256 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.MultiBuffer open Spec.Hash.Definitions open Hacl.Spec.SHA2.Vec open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST module Spec = Spec.Agile.Hash module SpecVec = Hacl.Spec.SHA2.Vec #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] private let sha224_init8 = init #SHA2_224 #M256 [@CInline] private let sha224_update8 = update #SHA2_224 #M256 [@CInline] private let sha224_update_nblocks8 = update_nblocks #SHA2_224 #M256 sha224_update8 [@CInline] private let sha224_update_last8 = update_last #SHA2_224 #M256 sha224_update8 [@CInline] private let sha224_finish8 = finish #SHA2_224 #M256 val sha224_8 (dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 : lbuffer uint8 28ul) (input_len:size_t) (input0 input1 input2 input3 input4 input5 input6 input7 : lbuffer uint8 input_len) : Stack unit (requires fun h0 -> v input_len `less_than_max_input_length` SHA2_224 /\ live8 h0 input0 input1 input2 input3 input4 input5 input6 input7 /\ live8 h0 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 /\ internally_disjoint8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7) (ensures fun h0 _ h1 -> modifies (loc dst0 |+| (loc dst1 |+| (loc dst2 |+| (loc dst3 |+| (loc dst4 |+| (loc dst5 |+| (loc dst6 |+| loc dst7))))))) h0 h1 /\ as_seq h1 dst0 == Spec.hash SHA2_224 (as_seq h0 input0) /\ as_seq h1 dst1 == Spec.hash SHA2_224 (as_seq h0 input1) /\ as_seq h1 dst2 == Spec.hash SHA2_224 (as_seq h0 input2) /\ as_seq h1 dst3 == Spec.hash SHA2_224 (as_seq h0 input3) /\ as_seq h1 dst4 == Spec.hash SHA2_224 (as_seq h0 input4) /\ as_seq h1 dst5 == Spec.hash SHA2_224 (as_seq h0 input5) /\ as_seq h1 dst6 == Spec.hash SHA2_224 (as_seq h0 input6) /\ as_seq h1 dst7 == Spec.hash SHA2_224 (as_seq h0 input7)) let sha224_8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 input_len input0 input1 input2 input3 input4 input5 input6 input7 = let ib = ntup8 (input0,(input1,(input2,(input3,(input4,(input5,(input6,input7))))))) in let rb = ntup8 (dst0,(dst1,(dst2,(dst3,(dst4,(dst5,(dst6,dst7))))))) in let h0 = ST.get() in assert (live_multi h0 ib); assert (live_multi h0 rb); assert (internally_disjoint rb); loc_multi8 rb; hash #SHA2_224 #M256 sha224_init8 sha224_update_nblocks8 sha224_update_last8 sha224_finish8 rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M256 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst0); assert ((as_seq_multi h1 rb).(|1|) == as_seq h1 dst1); assert ((as_seq_multi h1 rb).(|2|) == as_seq h1 dst2); assert ((as_seq_multi h1 rb).(|3|) == as_seq h1 dst3); assert ((as_seq_multi h1 rb).(|4|) == as_seq h1 dst4); assert ((as_seq_multi h1 rb).(|5|) == as_seq h1 dst5); assert ((as_seq_multi h1 rb).(|6|) == as_seq h1 dst6); assert ((as_seq_multi h1 rb).(|7|) == as_seq h1 dst7) [@CInline] private let sha256_init8 = init #SHA2_256 #M256 [@CInline] private let sha256_update8 = update #SHA2_256 #M256 [@CInline] private let sha256_update_nblocks8 = update_nblocks #SHA2_256 #M256 sha256_update8 [@CInline] private let sha256_update_last8 = update_last #SHA2_256 #M256 sha256_update8 [@CInline] private let sha256_finish8 = finish #SHA2_256 #M256 val sha256_8 (dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 : lbuffer uint8 32ul) (input_len:size_t) (input0 input1 input2 input3 input4 input5 input6 input7 : lbuffer uint8 input_len) : Stack unit (requires fun h0 -> v input_len `less_than_max_input_length` SHA2_256 /\ live8 h0 input0 input1 input2 input3 input4 input5 input6 input7 /\ live8 h0 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 /\ internally_disjoint8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7) (ensures fun h0 _ h1 -> modifies (loc dst0 |+| (loc dst1 |+| (loc dst2 |+| (loc dst3 |+| (loc dst4 |+| (loc dst5 |+| (loc dst6 |+| loc dst7))))))) h0 h1 /\ as_seq h1 dst0 == Spec.hash SHA2_256 (as_seq h0 input0) /\ as_seq h1 dst1 == Spec.hash SHA2_256 (as_seq h0 input1) /\ as_seq h1 dst2 == Spec.hash SHA2_256 (as_seq h0 input2) /\ as_seq h1 dst3 == Spec.hash SHA2_256 (as_seq h0 input3) /\ as_seq h1 dst4 == Spec.hash SHA2_256 (as_seq h0 input4) /\ as_seq h1 dst5 == Spec.hash SHA2_256 (as_seq h0 input5) /\ as_seq h1 dst6 == Spec.hash SHA2_256 (as_seq h0 input6) /\ as_seq h1 dst7 == Spec.hash SHA2_256 (as_seq h0 input7))
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Vec256.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
dst0: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> dst1: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> dst2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> dst3: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> dst4: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> dst5: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> dst6: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> dst7: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> input_len: Lib.IntTypes.size_t -> input0: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input1: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input2: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input3: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input4: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input5: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input6: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> input7: Lib.Buffer.lbuffer Lib.IntTypes.uint8 input_len -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Hash.Definitions.hash_len", "Spec.Hash.Definitions.SHA2_256", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.M256", "Lib.MultiBuffer.as_seq_multi", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.unit", "Hacl.Spec.SHA2.Equiv.hash_agile_lemma", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.SHA2.Generic.hash", "Hacl.SHA2.Vec256.sha256_init8", "Hacl.SHA2.Vec256.sha256_update_nblocks8", "Hacl.SHA2.Vec256.sha256_update_last8", "Hacl.SHA2.Vec256.sha256_finish8", "Lib.MultiBuffer.loc_multi8", "Lib.MultiBuffer.internally_disjoint", "Lib.MultiBuffer.live_multi", "Lib.NTuple.ntuple", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.NTuple.ntup8", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2" ]
[]
false
true
false
false
false
let sha256_8 dst0 dst1 dst2 dst3 dst4 dst5 dst6 dst7 input_len input0 input1 input2 input3 input4 input5 input6 input7 =
let ib = ntup8 (input0, (input1, (input2, (input3, (input4, (input5, (input6, input7))))))) in let rb = ntup8 (dst0, (dst1, (dst2, (dst3, (dst4, (dst5, (dst6, dst7))))))) in let h0 = ST.get () in assert (live_multi h0 ib); assert (live_multi h0 rb); assert (internally_disjoint rb); loc_multi8 rb; hash #SHA2_256 #M256 sha256_init8 sha256_update_nblocks8 sha256_update_last8 sha256_finish8 rb input_len ib; let h1 = ST.get () in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M256 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 dst0); assert ((as_seq_multi h1 rb).(| 1 |) == as_seq h1 dst1); assert ((as_seq_multi h1 rb).(| 2 |) == as_seq h1 dst2); assert ((as_seq_multi h1 rb).(| 3 |) == as_seq h1 dst3); assert ((as_seq_multi h1 rb).(| 4 |) == as_seq h1 dst4); assert ((as_seq_multi h1 rb).(| 5 |) == as_seq h1 dst5); assert ((as_seq_multi h1 rb).(| 6 |) == as_seq h1 dst6); assert ((as_seq_multi h1 rb).(| 7 |) == as_seq h1 dst7)
false
EngineTypes.fsti
EngineTypes.mk_engine_repr
val mk_engine_repr : l0_image_header_size: HACL.signable_len -> l0_image_header: Pulse.Lib.Vec.lvec FStar.UInt8.t (FStar.SizeT.v l0_image_header_size) -> l0_image_header_sig: Pulse.Lib.Vec.lvec FStar.UInt8.t 64 -> l0_binary_size: HACL.hashable_len -> l0_binary: Pulse.Lib.Vec.lvec FStar.UInt8.t (FStar.SizeT.v l0_binary_size) -> l0_binary_hash: Pulse.Lib.Vec.lvec FStar.UInt8.t (FStar.SizeT.v HACL.dice_digest_len) -> l0_image_auth_pubkey: Pulse.Lib.Vec.lvec FStar.UInt8.t 32 -> EngineTypes.engine_record_t
let mk_engine_repr l0_image_header_size l0_image_header l0_image_header_sig l0_binary_size l0_binary l0_binary_hash l0_image_auth_pubkey = {l0_image_header_size; l0_image_header; l0_image_header_sig; l0_binary_size; l0_binary; l0_binary_hash; l0_image_auth_pubkey}
{ "file_name": "share/steel/examples/pulse/dice/engine/EngineTypes.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 69, "end_line": 56, "start_col": 0, "start_line": 53 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EngineTypes open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module V = Pulse.Lib.Vec module US = FStar.SizeT module U8 = FStar.UInt8 open HACL val uds_is_enabled : vprop val uds_len : hashable_len type dice_return_code = | DICE_SUCCESS | DICE_ERROR let cdi_t = V.lvec U8.t (US.v (digest_len dice_hash_alg)) (* Engine Record *) noeq type engine_record_t = { l0_image_header_size : signable_len; l0_image_header : V.lvec U8.t (US.v l0_image_header_size); l0_image_header_sig : V.lvec U8.t 64; (* secret bytes *) l0_binary_size : hashable_len; l0_binary : V.lvec U8.t (US.v l0_binary_size); l0_binary_hash : V.lvec U8.t (US.v dice_digest_len); (*secret bytes *) l0_image_auth_pubkey : V.lvec U8.t 32; (* secret bytes *) } type engine_record_repr = { l0_image_header : Seq.seq U8.t; l0_image_header_sig : Seq.seq U8.t; l0_binary : Seq.seq U8.t; l0_binary_hash : Seq.seq U8.t; l0_image_auth_pubkey : Seq.seq U8.t; }
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Vec.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "prims.fst.checked", "HACL.fst.checked", "FStar.UInt8.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EngineTypes.fsti" }
[ { "abbrev": false, "full_module": "HACL", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Pulse.Lib.Vec", "short_module": "V" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
l0_image_header_size: HACL.signable_len -> l0_image_header: Pulse.Lib.Vec.lvec FStar.UInt8.t (FStar.SizeT.v l0_image_header_size) -> l0_image_header_sig: Pulse.Lib.Vec.lvec FStar.UInt8.t 64 -> l0_binary_size: HACL.hashable_len -> l0_binary: Pulse.Lib.Vec.lvec FStar.UInt8.t (FStar.SizeT.v l0_binary_size) -> l0_binary_hash: Pulse.Lib.Vec.lvec FStar.UInt8.t (FStar.SizeT.v HACL.dice_digest_len) -> l0_image_auth_pubkey: Pulse.Lib.Vec.lvec FStar.UInt8.t 32 -> EngineTypes.engine_record_t
Prims.Tot
[ "total" ]
[]
[ "HACL.signable_len", "Pulse.Lib.Vec.lvec", "FStar.UInt8.t", "FStar.SizeT.v", "HACL.hashable_len", "HACL.dice_digest_len", "EngineTypes.Mkengine_record_t", "EngineTypes.engine_record_t" ]
[]
false
false
false
false
false
let mk_engine_repr l0_image_header_size l0_image_header l0_image_header_sig l0_binary_size l0_binary l0_binary_hash l0_image_auth_pubkey =
{ l0_image_header_size = l0_image_header_size; l0_image_header = l0_image_header; l0_image_header_sig = l0_image_header_sig; l0_binary_size = l0_binary_size; l0_binary = l0_binary; l0_binary_hash = l0_binary_hash; l0_image_auth_pubkey = l0_image_auth_pubkey }
false
EngineTypes.fsti
EngineTypes.engine_record_perm
val engine_record_perm (record: engine_record_t) (p: perm) (repr: engine_record_repr) : vprop
val engine_record_perm (record: engine_record_t) (p: perm) (repr: engine_record_repr) : vprop
let engine_record_perm (record:engine_record_t) (p:perm) (repr:engine_record_repr) : vprop = V.pts_to record.l0_image_header #p repr.l0_image_header ** V.pts_to record.l0_image_header_sig #p repr.l0_image_header_sig ** V.pts_to record.l0_binary #p repr.l0_binary ** V.pts_to record.l0_binary_hash #p repr.l0_binary_hash ** V.pts_to record.l0_image_auth_pubkey #p repr.l0_image_auth_pubkey
{ "file_name": "share/steel/examples/pulse/dice/engine/EngineTypes.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 67, "end_line": 64, "start_col": 0, "start_line": 58 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EngineTypes open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module V = Pulse.Lib.Vec module US = FStar.SizeT module U8 = FStar.UInt8 open HACL val uds_is_enabled : vprop val uds_len : hashable_len type dice_return_code = | DICE_SUCCESS | DICE_ERROR let cdi_t = V.lvec U8.t (US.v (digest_len dice_hash_alg)) (* Engine Record *) noeq type engine_record_t = { l0_image_header_size : signable_len; l0_image_header : V.lvec U8.t (US.v l0_image_header_size); l0_image_header_sig : V.lvec U8.t 64; (* secret bytes *) l0_binary_size : hashable_len; l0_binary : V.lvec U8.t (US.v l0_binary_size); l0_binary_hash : V.lvec U8.t (US.v dice_digest_len); (*secret bytes *) l0_image_auth_pubkey : V.lvec U8.t 32; (* secret bytes *) } type engine_record_repr = { l0_image_header : Seq.seq U8.t; l0_image_header_sig : Seq.seq U8.t; l0_binary : Seq.seq U8.t; l0_binary_hash : Seq.seq U8.t; l0_image_auth_pubkey : Seq.seq U8.t; } let mk_engine_repr l0_image_header_size l0_image_header l0_image_header_sig l0_binary_size l0_binary l0_binary_hash l0_image_auth_pubkey = {l0_image_header_size; l0_image_header; l0_image_header_sig; l0_binary_size; l0_binary; l0_binary_hash; l0_image_auth_pubkey}
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Vec.fsti.checked", "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "prims.fst.checked", "HACL.fst.checked", "FStar.UInt8.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EngineTypes.fsti" }
[ { "abbrev": false, "full_module": "HACL", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Pulse.Lib.Vec", "short_module": "V" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
record: EngineTypes.engine_record_t -> p: PulseCore.FractionalPermission.perm -> repr: EngineTypes.engine_record_repr -> Pulse.Lib.Core.vprop
Prims.Tot
[ "total" ]
[]
[ "EngineTypes.engine_record_t", "PulseCore.FractionalPermission.perm", "EngineTypes.engine_record_repr", "Pulse.Lib.Core.op_Star_Star", "Pulse.Lib.Vec.pts_to", "FStar.UInt8.t", "EngineTypes.__proj__Mkengine_record_t__item__l0_image_header", "EngineTypes.__proj__Mkengine_record_repr__item__l0_image_header", "EngineTypes.__proj__Mkengine_record_t__item__l0_image_header_sig", "EngineTypes.__proj__Mkengine_record_repr__item__l0_image_header_sig", "EngineTypes.__proj__Mkengine_record_t__item__l0_binary", "EngineTypes.__proj__Mkengine_record_repr__item__l0_binary", "EngineTypes.__proj__Mkengine_record_t__item__l0_binary_hash", "EngineTypes.__proj__Mkengine_record_repr__item__l0_binary_hash", "EngineTypes.__proj__Mkengine_record_t__item__l0_image_auth_pubkey", "EngineTypes.__proj__Mkengine_record_repr__item__l0_image_auth_pubkey", "Pulse.Lib.Core.vprop" ]
[]
false
false
false
true
false
let engine_record_perm (record: engine_record_t) (p: perm) (repr: engine_record_repr) : vprop =
(((V.pts_to record.l0_image_header #p repr.l0_image_header ** V.pts_to record.l0_image_header_sig #p repr.l0_image_header_sig) ** V.pts_to record.l0_binary #p repr.l0_binary) ** V.pts_to record.l0_binary_hash #p repr.l0_binary_hash) ** V.pts_to record.l0_image_auth_pubkey #p repr.l0_image_auth_pubkey
false
EverCrypt.AEAD.fst
EverCrypt.AEAD.encrypt_expand_aes_gcm
val encrypt_expand_aes_gcm (i: vale_impl) : encrypt_expand_st false (alg_of_vale_impl i)
val encrypt_expand_aes_gcm (i: vale_impl) : encrypt_expand_st false (alg_of_vale_impl i)
let encrypt_expand_aes_gcm (i: vale_impl): encrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = encrypt_aes_gcm i s iv iv_len ad ad_len plain plain_len cipher tag in assert(r == Success); pop_frame (); Success
{ "file_name": "providers/evercrypt/fst/EverCrypt.AEAD.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 368, "start_col": 0, "start_line": 360 }
module EverCrypt.AEAD module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open FStar.Int.Cast open Spec.Agile.AEAD open Spec.Cipher.Expansion open EverCrypt.CTR.Keys friend Spec.Agile.AEAD friend Spec.Cipher.Expansion friend EverCrypt.CTR.Keys #set-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0" /// Defining abstract predicates, invariants, footprint, etc. /// --------------------------------------------------------- let _: squash (inversion impl) = allow_inversion impl /// We now distinguish between an expanded key (as mandated by NIST spec) and a /// **concrete** expanded key, which may contain implementation-specific details /// and extra precomputations. In the rest of this module, we rely on concrete /// expanded keys, which are parameterized over an implementation, instead of /// regular expanded keys, which are parameterized over an algorithm. Helpers /// allow us to move from one notion to the other. let supported_alg_of_impl (i: impl): supported_alg = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM | Hacl_CHACHA20 -> CHACHA20_POLY1305 inline_for_extraction noextract let alg_of_vale_impl (i: vale_impl) = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM noeq type state_s a = | Ek: impl:impl -> kv:G.erased (kv a) -> ek:B.buffer UInt8.t -> // concrete expanded key state_s a let invert_state_s (a: alg): Lemma (requires True) (ensures (inversion (state_s a))) [ SMTPat (state_s a) ] = allow_inversion (state_s a) let freeable_s #a (Ek _ _ ek) = B.freeable ek let footprint_s #a (Ek _ _ ek) = B.loc_addr_of_buffer ek let invariant_s #a h (Ek i kv ek) = is_supported_alg a /\ a = supported_alg_of_impl i /\ B.live h ek /\ B.length ek >= concrete_xkey_length i /\ B.as_seq h (B.gsub ek 0ul (UInt32.uint_to_t (concrete_xkey_length i))) `S.equal` concrete_expand i (G.reveal kv) /\ config_pre a /\ ( match i with | Vale_AES128 | Vale_AES256 -> // Expanded key length + precomputed stuff + scratch space (AES-GCM specific) B.length ek = vale_xkey_length (cipher_alg_of_supported_alg a) + 176 | Hacl_CHACHA20 -> B.length ek = concrete_xkey_length i) let invariant_loc_in_footprint #a s m = () let frame_invariant #a l s h0 h1 = () /// Actual stateful API /// ------------------- let alg_of_state a s = let open LowStar.BufferOps in let Ek impl _ _ = !*s in match impl with | Hacl_CHACHA20 -> CHACHA20_POLY1305 | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM let as_kv #a (Ek _ kv _) = G.reveal kv #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" let create_in_chacha20_poly1305: create_in_st CHACHA20_POLY1305 = fun r dst k -> let h0 = ST.get () in let ek = B.malloc r 0uy 32ul in let p = B.malloc r (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; B.upd dst 0ul p; let h2 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h0 h2; Success #pop-options inline_for_extraction noextract let create_in_aes_gcm (i: vale_impl): create_in_st (alg_of_vale_impl i) = fun r dst k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in if EverCrypt.TargetConfig.hacl_can_compile_vale then ( let has_aesni = EverCrypt.AutoConfig2.has_aesni () in let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then ( let ek = B.malloc r 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.malloc r (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in let open LowStar.BufferOps in dst *= p; let h3 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h2 h3; Success ) else UnsupportedAlgorithm ) else UnsupportedAlgorithm let create_in_aes128_gcm: create_in_st AES128_GCM = create_in_aes_gcm Vale_AES128 let create_in_aes256_gcm: create_in_st AES256_GCM = create_in_aes_gcm Vale_AES256 let create_in #a r dst k = match a with | AES128_GCM -> create_in_aes128_gcm r dst k | AES256_GCM -> create_in_aes256_gcm r dst k | CHACHA20_POLY1305 -> create_in_chacha20_poly1305 r dst k | _ -> UnsupportedAlgorithm #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" inline_for_extraction noextract let alloca_chacha20_poly1305: alloca_st CHACHA20_POLY1305 = fun k -> let h0 = ST.get () in let ek = B.alloca 0uy 32ul in let p = B.alloca (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; let h3 = ST.get() in B.modifies_only_not_unused_in B.loc_none h0 h3; p #pop-options inline_for_extraction noextract let alloca_aes_gcm (i: vale_impl): alloca_st (alg_of_vale_impl i) = fun k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in let ek = B.alloca 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.alloca (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in p inline_for_extraction noextract let alloca_aes128_gcm: alloca_st AES128_GCM = alloca_aes_gcm Vale_AES128 inline_for_extraction noextract let alloca_aes256_gcm: alloca_st AES256_GCM = alloca_aes_gcm Vale_AES256 let alloca #a k = match a with | AES128_GCM -> alloca_aes128_gcm k | AES256_GCM -> alloca_aes256_gcm k | CHACHA20_POLY1305 -> alloca_chacha20_poly1305 k inline_for_extraction noextract let aes_gcm_encrypt (i: vale_impl): Vale.Wrapper.X64.GCMencryptOpt.encrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMencryptOpt256.gcm256_encrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let encrypt_aes_gcm (i: vale_impl): encrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if B.is_null s then InvalidKey else let a = alg_of_vale_impl i in // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let h0 = get() in aes_gcm_encrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) plain (uint32_to_uint64 plain_len) ad (uint32_to_uint64 ad_len) tmp_iv cipher tag keys_b hkeys_b scratch_b; let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // and tag. It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 plain) in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in Seq.equal (B.as_seq h1 cipher) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat) /\ Seq.equal (B.as_seq h1 tag) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat)); pop_frame(); Success let encrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES128_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES256_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt #a s iv iv_len ad ad_len plain plain_len cipher tag = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> encrypt_aes128_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Vale_AES256 -> encrypt_aes256_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Hacl_CHACHA20 -> // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin // Length restrictions assert_norm (pow2 31 + pow2 32 / 64 <= pow2 32 - 1); EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; Success end
{ "checked_file": "/", "dependencies": [ "Vale.Wrapper.X64.GCMencryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMencryptOpt.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt.fsti.checked", "Vale.Wrapper.X64.GCM_IV.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Agile.AEAD.fst.checked", "Spec.Agile.AEAD.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.Chacha20Poly1305.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AEAD.fst" }
[ { "abbrev": false, "full_module": "EverCrypt.CTR.Keys", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher.Expansion", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "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": 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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: EverCrypt.CTR.Keys.vale_impl -> EverCrypt.AEAD.encrypt_expand_st false (EverCrypt.AEAD.alg_of_vale_impl i)
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.CTR.Keys.vale_impl", "LowStar.Buffer.buffer", "EverCrypt.CTR.Keys.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "EverCrypt.AEAD.alg_of_vale_impl", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "FStar.Integers.op_Greater", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.plain_p", "Spec.Agile.AEAD.max_length", "Prims.nat", "Spec.Agile.AEAD.tag_length", "EverCrypt.Error.Success", "EverCrypt.Error.error_code", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Prims._assert", "Prims.eq2", "EverCrypt.AEAD.encrypt_aes_gcm", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.state_s", "EverCrypt.AEAD.alloca", "LowStar.Buffer.pointer", "FStar.HyperStack.ST.push_frame", "EverCrypt.AEAD.encrypt_expand_st" ]
[]
false
false
false
false
false
let encrypt_expand_aes_gcm (i: vale_impl) : encrypt_expand_st false (alg_of_vale_impl i) =
fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); let s:B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = encrypt_aes_gcm i s iv iv_len ad ad_len plain plain_len cipher tag in assert (r == Success); pop_frame (); Success
false
Hacl.P256.PrecompTable.fst
Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lemma_w4
val precomp_g_pow2_128_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_128 16 precomp_g_pow2_128_table_lseq_w4 i)
val precomp_g_pow2_128_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_128 16 precomp_g_pow2_128_table_lseq_w4 i)
let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma ()
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 251, "start_col": 0, "start_line": 247 }
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4
{ "checked_file": "/", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 16}). Hacl.P256.PrecompTable.precomp_table_acc_inv Hacl.P256.PrecompTable.g_pow2_128 16 Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lseq_w4 i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.P256.PrecompTable.proj_g_pow2_128_lemma", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.P256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_128", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
true
false
true
false
false
let precomp_g_pow2_128_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma ()
false
Steel.PCMReference.fst
Steel.PCMReference.alloc
val alloc (#a:Type) (#pcm:pcm a) (x:a) : Steel (ref a pcm) emp (fun r -> pts_to r x) (requires fun _ -> pcm.refine x) (ensures fun _ _ _ -> True)
val alloc (#a:Type) (#pcm:pcm a) (x:a) : Steel (ref a pcm) emp (fun r -> pts_to r x) (requires fun _ -> pcm.refine x) (ensures fun _ _ _ -> True)
let alloc #_ #pcm x = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); compatible_refl pcm x; alloc' x
{ "file_name": "lib/steel/Steel.PCMReference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 38, "start_col": 0, "start_line": 36 }
(* Copyright 2020 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 Steel.PCMReference module Mem = Steel.Memory let read r v0 = let v = as_action (sel_action FStar.Set.empty r v0) in v let write r v0 v1 = as_action (upd_action FStar.Set.empty r v0 v1) val alloc' (#a:Type) (#pcm:pcm a) (x:a) : Steel (ref a pcm) (to_vprop Mem.emp) (fun r -> pts_to r x) (requires fun _ -> compatible pcm x x /\ pcm.refine x) (ensures fun _ _ _ -> True) let alloc' x = as_action (alloc_action FStar.Set.empty x)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked" ], "interface_file": true, "source_file": "Steel.PCMReference.fst" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Steel.Effect.Steel (Steel.Memory.ref a pcm)
Steel.Effect.Steel
[]
[]
[ "FStar.PCM.pcm", "Steel.PCMReference.alloc'", "Steel.Memory.ref", "Prims.unit", "FStar.PCM.compatible_refl", "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.emp", "Steel.Effect.Common.to_vprop", "Steel.Memory.emp", "Steel.Memory.mem", "Steel.Effect.Common.reveal_emp" ]
[]
false
true
false
false
false
let alloc #_ #pcm x =
rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); compatible_refl pcm x; alloc' x
false
Steel.PCMReference.fst
Steel.PCMReference.gather
val gather (#inames: _) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:erased a) (v1:erased a) : SteelGhostT (_:unit{composable p v0 v1}) inames (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1))
val gather (#inames: _) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:erased a) (v1:erased a) : SteelGhostT (_:unit{composable p v0 v1}) inames (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1))
let gather r v0 v1 = rewrite_slprop (pts_to r v0 `star` pts_to r v1) (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (fun _ -> ()); gather' r v0 v1
{ "file_name": "lib/steel/Steel.PCMReference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 17, "end_line": 79, "start_col": 0, "start_line": 75 }
(* Copyright 2020 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 Steel.PCMReference module Mem = Steel.Memory let read r v0 = let v = as_action (sel_action FStar.Set.empty r v0) in v let write r v0 v1 = as_action (upd_action FStar.Set.empty r v0 v1) val alloc' (#a:Type) (#pcm:pcm a) (x:a) : Steel (ref a pcm) (to_vprop Mem.emp) (fun r -> pts_to r x) (requires fun _ -> compatible pcm x x /\ pcm.refine x) (ensures fun _ _ _ -> True) let alloc' x = as_action (alloc_action FStar.Set.empty x) let alloc #_ #pcm x = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); compatible_refl pcm x; alloc' x let free r x = as_action (free_action FStar.Set.empty r x) val split' (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v0:erased a) (v1:erased a{composable p v0 v1}) : SteelGhostT unit inames (pts_to r (op p v0 v1)) (fun _ -> to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) let split' #inames #a #p r v0 v1 = as_atomic_action_ghost (split_action inames r v0 v1) let split #_ #a #p r v v0 v1 = let _:squash (composable p v0 v1) = () in rewrite_slprop (pts_to r v) (pts_to r (op p v0 v1)) (fun _ -> ()); split' r v0 v1; rewrite_slprop (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (pts_to r v0 `star` pts_to r v1) (fun _ -> ()) val gather' (#inames: _) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:erased a) (v1:erased a) : SteelGhostT (_:unit{composable p v0 v1}) inames (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (fun _ -> pts_to r (op p v0 v1)) let gather' #inames r v0 v1 = as_atomic_action_ghost (gather_action inames r v0 v1)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked" ], "interface_file": true, "source_file": "Steel.PCMReference.fst" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
r: Steel.Memory.ref a p -> v0: FStar.Ghost.erased a -> v1: FStar.Ghost.erased a -> Steel.Effect.Atomic.SteelGhostT (_: Prims.unit{FStar.PCM.composable p (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1)})
Steel.Effect.Atomic.SteelGhostT
[]
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.PCMReference.gather'", "Prims.unit", "FStar.PCM.composable", "FStar.Ghost.reveal", "Steel.Effect.Atomic.rewrite_slprop", "Steel.Effect.Common.star", "Steel.PCMReference.pts_to", "Steel.Effect.Common.to_vprop", "Steel.Memory.star", "Steel.Memory.pts_to", "Steel.Memory.mem" ]
[]
false
true
false
false
false
let gather r v0 v1 =
rewrite_slprop ((pts_to r v0) `star` (pts_to r v1)) (to_vprop Mem.((pts_to r v0) `star` (pts_to r v1))) (fun _ -> ()); gather' r v0 v1
false
EverCrypt.AEAD.fst
EverCrypt.AEAD.encrypt_expand_chacha20_poly1305
val encrypt_expand_chacha20_poly1305: encrypt_expand_st false CHACHA20_POLY1305
val encrypt_expand_chacha20_poly1305: encrypt_expand_st false CHACHA20_POLY1305
let encrypt_expand_chacha20_poly1305 : encrypt_expand_st false CHACHA20_POLY1305 = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s CHACHA20_POLY1305) = alloca k in let open LowStar.BufferOps in let Ek i kv ek = !*s in EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; pop_frame (); Success
{ "file_name": "providers/evercrypt/fst/EverCrypt.AEAD.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 423, "start_col": 0, "start_line": 414 }
module EverCrypt.AEAD module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open FStar.Int.Cast open Spec.Agile.AEAD open Spec.Cipher.Expansion open EverCrypt.CTR.Keys friend Spec.Agile.AEAD friend Spec.Cipher.Expansion friend EverCrypt.CTR.Keys #set-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0" /// Defining abstract predicates, invariants, footprint, etc. /// --------------------------------------------------------- let _: squash (inversion impl) = allow_inversion impl /// We now distinguish between an expanded key (as mandated by NIST spec) and a /// **concrete** expanded key, which may contain implementation-specific details /// and extra precomputations. In the rest of this module, we rely on concrete /// expanded keys, which are parameterized over an implementation, instead of /// regular expanded keys, which are parameterized over an algorithm. Helpers /// allow us to move from one notion to the other. let supported_alg_of_impl (i: impl): supported_alg = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM | Hacl_CHACHA20 -> CHACHA20_POLY1305 inline_for_extraction noextract let alg_of_vale_impl (i: vale_impl) = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM noeq type state_s a = | Ek: impl:impl -> kv:G.erased (kv a) -> ek:B.buffer UInt8.t -> // concrete expanded key state_s a let invert_state_s (a: alg): Lemma (requires True) (ensures (inversion (state_s a))) [ SMTPat (state_s a) ] = allow_inversion (state_s a) let freeable_s #a (Ek _ _ ek) = B.freeable ek let footprint_s #a (Ek _ _ ek) = B.loc_addr_of_buffer ek let invariant_s #a h (Ek i kv ek) = is_supported_alg a /\ a = supported_alg_of_impl i /\ B.live h ek /\ B.length ek >= concrete_xkey_length i /\ B.as_seq h (B.gsub ek 0ul (UInt32.uint_to_t (concrete_xkey_length i))) `S.equal` concrete_expand i (G.reveal kv) /\ config_pre a /\ ( match i with | Vale_AES128 | Vale_AES256 -> // Expanded key length + precomputed stuff + scratch space (AES-GCM specific) B.length ek = vale_xkey_length (cipher_alg_of_supported_alg a) + 176 | Hacl_CHACHA20 -> B.length ek = concrete_xkey_length i) let invariant_loc_in_footprint #a s m = () let frame_invariant #a l s h0 h1 = () /// Actual stateful API /// ------------------- let alg_of_state a s = let open LowStar.BufferOps in let Ek impl _ _ = !*s in match impl with | Hacl_CHACHA20 -> CHACHA20_POLY1305 | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM let as_kv #a (Ek _ kv _) = G.reveal kv #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" let create_in_chacha20_poly1305: create_in_st CHACHA20_POLY1305 = fun r dst k -> let h0 = ST.get () in let ek = B.malloc r 0uy 32ul in let p = B.malloc r (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; B.upd dst 0ul p; let h2 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h0 h2; Success #pop-options inline_for_extraction noextract let create_in_aes_gcm (i: vale_impl): create_in_st (alg_of_vale_impl i) = fun r dst k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in if EverCrypt.TargetConfig.hacl_can_compile_vale then ( let has_aesni = EverCrypt.AutoConfig2.has_aesni () in let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then ( let ek = B.malloc r 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.malloc r (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in let open LowStar.BufferOps in dst *= p; let h3 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h2 h3; Success ) else UnsupportedAlgorithm ) else UnsupportedAlgorithm let create_in_aes128_gcm: create_in_st AES128_GCM = create_in_aes_gcm Vale_AES128 let create_in_aes256_gcm: create_in_st AES256_GCM = create_in_aes_gcm Vale_AES256 let create_in #a r dst k = match a with | AES128_GCM -> create_in_aes128_gcm r dst k | AES256_GCM -> create_in_aes256_gcm r dst k | CHACHA20_POLY1305 -> create_in_chacha20_poly1305 r dst k | _ -> UnsupportedAlgorithm #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" inline_for_extraction noextract let alloca_chacha20_poly1305: alloca_st CHACHA20_POLY1305 = fun k -> let h0 = ST.get () in let ek = B.alloca 0uy 32ul in let p = B.alloca (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; let h3 = ST.get() in B.modifies_only_not_unused_in B.loc_none h0 h3; p #pop-options inline_for_extraction noextract let alloca_aes_gcm (i: vale_impl): alloca_st (alg_of_vale_impl i) = fun k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in let ek = B.alloca 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.alloca (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in p inline_for_extraction noextract let alloca_aes128_gcm: alloca_st AES128_GCM = alloca_aes_gcm Vale_AES128 inline_for_extraction noextract let alloca_aes256_gcm: alloca_st AES256_GCM = alloca_aes_gcm Vale_AES256 let alloca #a k = match a with | AES128_GCM -> alloca_aes128_gcm k | AES256_GCM -> alloca_aes256_gcm k | CHACHA20_POLY1305 -> alloca_chacha20_poly1305 k inline_for_extraction noextract let aes_gcm_encrypt (i: vale_impl): Vale.Wrapper.X64.GCMencryptOpt.encrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMencryptOpt256.gcm256_encrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let encrypt_aes_gcm (i: vale_impl): encrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if B.is_null s then InvalidKey else let a = alg_of_vale_impl i in // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let h0 = get() in aes_gcm_encrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) plain (uint32_to_uint64 plain_len) ad (uint32_to_uint64 ad_len) tmp_iv cipher tag keys_b hkeys_b scratch_b; let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // and tag. It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 plain) in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in Seq.equal (B.as_seq h1 cipher) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat) /\ Seq.equal (B.as_seq h1 tag) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat)); pop_frame(); Success let encrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES128_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES256_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt #a s iv iv_len ad ad_len plain plain_len cipher tag = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> encrypt_aes128_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Vale_AES256 -> encrypt_aes256_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Hacl_CHACHA20 -> // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin // Length restrictions assert_norm (pow2 31 + pow2 32 / 64 <= pow2 32 - 1); EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; Success end inline_for_extraction noextract let encrypt_expand_aes_gcm (i: vale_impl): encrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = encrypt_aes_gcm i s iv iv_len ad ad_len plain plain_len cipher tag in assert(r == Success); pop_frame (); Success let encrypt_expand_aes128_gcm_no_check : encrypt_expand_st false AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes256_gcm_no_check : encrypt_expand_st false AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes128_gcm : encrypt_expand_st true AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_aes256_gcm : encrypt_expand_st true AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm
{ "checked_file": "/", "dependencies": [ "Vale.Wrapper.X64.GCMencryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMencryptOpt.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt.fsti.checked", "Vale.Wrapper.X64.GCM_IV.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Agile.AEAD.fst.checked", "Spec.Agile.AEAD.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.Chacha20Poly1305.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AEAD.fst" }
[ { "abbrev": false, "full_module": "EverCrypt.CTR.Keys", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher.Expansion", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "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": 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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AEAD.encrypt_expand_st false Spec.Agile.AEAD.CHACHA20_POLY1305
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.buffer", "EverCrypt.CTR.Keys.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "Spec.Agile.AEAD.CHACHA20_POLY1305", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "FStar.Integers.op_Greater", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.plain_p", "Spec.Agile.AEAD.max_length", "Prims.nat", "Spec.Agile.AEAD.tag_length", "Spec.Cipher.Expansion.impl", "FStar.Ghost.erased", "Spec.Agile.AEAD.kv", "FStar.UInt8.t", "EverCrypt.Error.Success", "EverCrypt.Error.error_code", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "EverCrypt.Chacha20Poly1305.aead_encrypt", "EverCrypt.AEAD.state_s", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.alloca", "LowStar.Buffer.pointer", "FStar.HyperStack.ST.push_frame", "EverCrypt.AEAD.encrypt_expand_st" ]
[]
false
false
false
false
false
let encrypt_expand_chacha20_poly1305:encrypt_expand_st false CHACHA20_POLY1305 =
fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); let s:B.pointer_or_null (state_s CHACHA20_POLY1305) = alloca k in let open LowStar.BufferOps in let Ek i kv ek = !*s in EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; pop_frame (); Success
false
Hacl.P256.PrecompTable.fst
Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lseq_w4
val precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192
val precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192
let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 245, "start_col": 0, "start_line": 243 }
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15)
{ "checked_file": "/", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.uint64 192
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq_of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_g_pow2_128_table_list_w4", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.uint_to_t", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_128", "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
false
false
false
false
false
let precomp_g_pow2_128_table_lseq_w4:LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4
false
EverCrypt.AEAD.fst
EverCrypt.AEAD.encrypt_aes_gcm
val encrypt_aes_gcm (i: vale_impl) : encrypt_st (alg_of_vale_impl i)
val encrypt_aes_gcm (i: vale_impl) : encrypt_st (alg_of_vale_impl i)
let encrypt_aes_gcm (i: vale_impl): encrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if B.is_null s then InvalidKey else let a = alg_of_vale_impl i in // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let h0 = get() in aes_gcm_encrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) plain (uint32_to_uint64 plain_len) ad (uint32_to_uint64 ad_len) tmp_iv cipher tag keys_b hkeys_b scratch_b; let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // and tag. It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 plain) in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in Seq.equal (B.as_seq h1 cipher) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat) /\ Seq.equal (B.as_seq h1 tag) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat)); pop_frame(); Success
{ "file_name": "providers/evercrypt/fst/EverCrypt.AEAD.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 315, "start_col": 0, "start_line": 214 }
module EverCrypt.AEAD module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open FStar.Int.Cast open Spec.Agile.AEAD open Spec.Cipher.Expansion open EverCrypt.CTR.Keys friend Spec.Agile.AEAD friend Spec.Cipher.Expansion friend EverCrypt.CTR.Keys #set-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0" /// Defining abstract predicates, invariants, footprint, etc. /// --------------------------------------------------------- let _: squash (inversion impl) = allow_inversion impl /// We now distinguish between an expanded key (as mandated by NIST spec) and a /// **concrete** expanded key, which may contain implementation-specific details /// and extra precomputations. In the rest of this module, we rely on concrete /// expanded keys, which are parameterized over an implementation, instead of /// regular expanded keys, which are parameterized over an algorithm. Helpers /// allow us to move from one notion to the other. let supported_alg_of_impl (i: impl): supported_alg = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM | Hacl_CHACHA20 -> CHACHA20_POLY1305 inline_for_extraction noextract let alg_of_vale_impl (i: vale_impl) = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM noeq type state_s a = | Ek: impl:impl -> kv:G.erased (kv a) -> ek:B.buffer UInt8.t -> // concrete expanded key state_s a let invert_state_s (a: alg): Lemma (requires True) (ensures (inversion (state_s a))) [ SMTPat (state_s a) ] = allow_inversion (state_s a) let freeable_s #a (Ek _ _ ek) = B.freeable ek let footprint_s #a (Ek _ _ ek) = B.loc_addr_of_buffer ek let invariant_s #a h (Ek i kv ek) = is_supported_alg a /\ a = supported_alg_of_impl i /\ B.live h ek /\ B.length ek >= concrete_xkey_length i /\ B.as_seq h (B.gsub ek 0ul (UInt32.uint_to_t (concrete_xkey_length i))) `S.equal` concrete_expand i (G.reveal kv) /\ config_pre a /\ ( match i with | Vale_AES128 | Vale_AES256 -> // Expanded key length + precomputed stuff + scratch space (AES-GCM specific) B.length ek = vale_xkey_length (cipher_alg_of_supported_alg a) + 176 | Hacl_CHACHA20 -> B.length ek = concrete_xkey_length i) let invariant_loc_in_footprint #a s m = () let frame_invariant #a l s h0 h1 = () /// Actual stateful API /// ------------------- let alg_of_state a s = let open LowStar.BufferOps in let Ek impl _ _ = !*s in match impl with | Hacl_CHACHA20 -> CHACHA20_POLY1305 | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM let as_kv #a (Ek _ kv _) = G.reveal kv #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" let create_in_chacha20_poly1305: create_in_st CHACHA20_POLY1305 = fun r dst k -> let h0 = ST.get () in let ek = B.malloc r 0uy 32ul in let p = B.malloc r (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; B.upd dst 0ul p; let h2 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h0 h2; Success #pop-options inline_for_extraction noextract let create_in_aes_gcm (i: vale_impl): create_in_st (alg_of_vale_impl i) = fun r dst k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in if EverCrypt.TargetConfig.hacl_can_compile_vale then ( let has_aesni = EverCrypt.AutoConfig2.has_aesni () in let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then ( let ek = B.malloc r 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.malloc r (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in let open LowStar.BufferOps in dst *= p; let h3 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h2 h3; Success ) else UnsupportedAlgorithm ) else UnsupportedAlgorithm let create_in_aes128_gcm: create_in_st AES128_GCM = create_in_aes_gcm Vale_AES128 let create_in_aes256_gcm: create_in_st AES256_GCM = create_in_aes_gcm Vale_AES256 let create_in #a r dst k = match a with | AES128_GCM -> create_in_aes128_gcm r dst k | AES256_GCM -> create_in_aes256_gcm r dst k | CHACHA20_POLY1305 -> create_in_chacha20_poly1305 r dst k | _ -> UnsupportedAlgorithm #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" inline_for_extraction noextract let alloca_chacha20_poly1305: alloca_st CHACHA20_POLY1305 = fun k -> let h0 = ST.get () in let ek = B.alloca 0uy 32ul in let p = B.alloca (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; let h3 = ST.get() in B.modifies_only_not_unused_in B.loc_none h0 h3; p #pop-options inline_for_extraction noextract let alloca_aes_gcm (i: vale_impl): alloca_st (alg_of_vale_impl i) = fun k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in let ek = B.alloca 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.alloca (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in p inline_for_extraction noextract let alloca_aes128_gcm: alloca_st AES128_GCM = alloca_aes_gcm Vale_AES128 inline_for_extraction noextract let alloca_aes256_gcm: alloca_st AES256_GCM = alloca_aes_gcm Vale_AES256 let alloca #a k = match a with | AES128_GCM -> alloca_aes128_gcm k | AES256_GCM -> alloca_aes256_gcm k | CHACHA20_POLY1305 -> alloca_chacha20_poly1305 k inline_for_extraction noextract let aes_gcm_encrypt (i: vale_impl): Vale.Wrapper.X64.GCMencryptOpt.encrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMencryptOpt256.gcm256_encrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'"
{ "checked_file": "/", "dependencies": [ "Vale.Wrapper.X64.GCMencryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMencryptOpt.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt.fsti.checked", "Vale.Wrapper.X64.GCM_IV.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Agile.AEAD.fst.checked", "Spec.Agile.AEAD.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.Chacha20Poly1305.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AEAD.fst" }
[ { "abbrev": false, "full_module": "EverCrypt.CTR.Keys", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher.Expansion", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "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": 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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: EverCrypt.CTR.Keys.vale_impl -> EverCrypt.AEAD.encrypt_st (EverCrypt.AEAD.alg_of_vale_impl i)
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.CTR.Keys.vale_impl", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.state_s", "EverCrypt.AEAD.alg_of_vale_impl", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "LowStar.Monotonic.Buffer.length", "EverCrypt.CTR.Keys.uint8", "LowStar.Buffer.trivial_preorder", "FStar.Integers.op_Greater", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.plain_p", "Spec.Agile.AEAD.max_length", "LowStar.Buffer.buffer", "Prims.nat", "Spec.Agile.AEAD.tag_length", "EverCrypt.Error.InvalidKey", "EverCrypt.Error.error_code", "Prims.bool", "FStar.UInt32.__uint_to_t", "EverCrypt.Error.InvalidIVLength", "Spec.Cipher.Expansion.impl", "FStar.Ghost.erased", "Spec.Agile.AEAD.kv", "FStar.UInt8.t", "EverCrypt.Error.Success", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Prims._assert", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "FStar.Seq.Base.equal", "LowStar.Monotonic.Buffer.as_seq", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8", "FStar.Pervasives.Native.tuple2", "Vale.Def.Words_s.nat8", "Vale.AES.GCM_s.gcm_encrypt_LE", "Spec.Agile.AEAD.vale_alg_of_alg", "Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8", "FStar.Ghost.reveal", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverCrypt.AEAD.aes_gcm_encrypt", "FStar.Ghost.hide", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.nat32", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Int.Cast.uint32_to_uint64", "Vale.Wrapper.X64.GCM_IV.compute_iv", "Prims.l_True", "Prims.squash", "Vale.AES.OptPublic.hkeys_reqs_pub", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.Def.Words_s.Mkfour", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Calc.calc_finish", "Vale.Def.Types_s.quad32", "Prims.eq2", "Prims.Cons", "FStar.Preorder.relation", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "FStar.Seq.Properties.lseq", "Vale.AES.OptPublic.get_hkeys_reqs", "LowStar.Monotonic.Buffer.mbuffer", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca", "FStar.UInt8.__uint_to_t", "LowStar.Buffer.sub", "EverCrypt.CTR.Keys.key_offset", "EverCrypt.CTR.Keys.concrete_xkey_len", "FStar.HyperStack.ST.push_frame", "Vale.AES.AES_s.is_aes_key_LE", "LowStar.BufferOps.op_Bang_Star", "Spec.Agile.AEAD.alg", "LowStar.Monotonic.Buffer.is_null", "EverCrypt.AEAD.encrypt_st" ]
[]
false
false
false
false
false
let encrypt_aes_gcm (i: vale_impl) : encrypt_st (alg_of_vale_impl i) =
fun s iv iv_len ad ad_len plain plain_len cipher tag -> if B.is_null s then InvalidKey else let a = alg_of_vale_impl i in if iv_len = 0ul then InvalidIVLength else let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame (); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get () in let tmp_iv = B.alloca 0uy 16ul in let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad ) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc ( == ) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); ( == ) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) iv iv_len tmp_iv tmp_iv hkeys_b; let h0 = get () in aes_gcm_encrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) plain (uint32_to_uint64 plain_len) ad (uint32_to_uint64 ad_len) tmp_iv cipher tag keys_b hkeys_b scratch_b; let h1 = get () in assert (let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 plain) in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in Seq.equal (B.as_seq h1 cipher) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat) /\ Seq.equal (B.as_seq h1 tag) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat)); pop_frame (); Success
false
EverCrypt.AEAD.fst
EverCrypt.AEAD.decrypt_expand_aes_gcm
val decrypt_expand_aes_gcm (i: vale_impl) : decrypt_expand_st false (alg_of_vale_impl i)
val decrypt_expand_aes_gcm (i: vale_impl) : decrypt_expand_st false (alg_of_vale_impl i)
let decrypt_expand_aes_gcm (i: vale_impl): decrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = decrypt_aes_gcm i s iv iv_len ad ad_len cipher cipher_len tag dst in pop_frame (); r
{ "file_name": "providers/evercrypt/fst/EverCrypt.AEAD.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 628, "start_col": 0, "start_line": 621 }
module EverCrypt.AEAD module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open FStar.Int.Cast open Spec.Agile.AEAD open Spec.Cipher.Expansion open EverCrypt.CTR.Keys friend Spec.Agile.AEAD friend Spec.Cipher.Expansion friend EverCrypt.CTR.Keys #set-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0" /// Defining abstract predicates, invariants, footprint, etc. /// --------------------------------------------------------- let _: squash (inversion impl) = allow_inversion impl /// We now distinguish between an expanded key (as mandated by NIST spec) and a /// **concrete** expanded key, which may contain implementation-specific details /// and extra precomputations. In the rest of this module, we rely on concrete /// expanded keys, which are parameterized over an implementation, instead of /// regular expanded keys, which are parameterized over an algorithm. Helpers /// allow us to move from one notion to the other. let supported_alg_of_impl (i: impl): supported_alg = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM | Hacl_CHACHA20 -> CHACHA20_POLY1305 inline_for_extraction noextract let alg_of_vale_impl (i: vale_impl) = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM noeq type state_s a = | Ek: impl:impl -> kv:G.erased (kv a) -> ek:B.buffer UInt8.t -> // concrete expanded key state_s a let invert_state_s (a: alg): Lemma (requires True) (ensures (inversion (state_s a))) [ SMTPat (state_s a) ] = allow_inversion (state_s a) let freeable_s #a (Ek _ _ ek) = B.freeable ek let footprint_s #a (Ek _ _ ek) = B.loc_addr_of_buffer ek let invariant_s #a h (Ek i kv ek) = is_supported_alg a /\ a = supported_alg_of_impl i /\ B.live h ek /\ B.length ek >= concrete_xkey_length i /\ B.as_seq h (B.gsub ek 0ul (UInt32.uint_to_t (concrete_xkey_length i))) `S.equal` concrete_expand i (G.reveal kv) /\ config_pre a /\ ( match i with | Vale_AES128 | Vale_AES256 -> // Expanded key length + precomputed stuff + scratch space (AES-GCM specific) B.length ek = vale_xkey_length (cipher_alg_of_supported_alg a) + 176 | Hacl_CHACHA20 -> B.length ek = concrete_xkey_length i) let invariant_loc_in_footprint #a s m = () let frame_invariant #a l s h0 h1 = () /// Actual stateful API /// ------------------- let alg_of_state a s = let open LowStar.BufferOps in let Ek impl _ _ = !*s in match impl with | Hacl_CHACHA20 -> CHACHA20_POLY1305 | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM let as_kv #a (Ek _ kv _) = G.reveal kv #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" let create_in_chacha20_poly1305: create_in_st CHACHA20_POLY1305 = fun r dst k -> let h0 = ST.get () in let ek = B.malloc r 0uy 32ul in let p = B.malloc r (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; B.upd dst 0ul p; let h2 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h0 h2; Success #pop-options inline_for_extraction noextract let create_in_aes_gcm (i: vale_impl): create_in_st (alg_of_vale_impl i) = fun r dst k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in if EverCrypt.TargetConfig.hacl_can_compile_vale then ( let has_aesni = EverCrypt.AutoConfig2.has_aesni () in let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then ( let ek = B.malloc r 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.malloc r (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in let open LowStar.BufferOps in dst *= p; let h3 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h2 h3; Success ) else UnsupportedAlgorithm ) else UnsupportedAlgorithm let create_in_aes128_gcm: create_in_st AES128_GCM = create_in_aes_gcm Vale_AES128 let create_in_aes256_gcm: create_in_st AES256_GCM = create_in_aes_gcm Vale_AES256 let create_in #a r dst k = match a with | AES128_GCM -> create_in_aes128_gcm r dst k | AES256_GCM -> create_in_aes256_gcm r dst k | CHACHA20_POLY1305 -> create_in_chacha20_poly1305 r dst k | _ -> UnsupportedAlgorithm #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" inline_for_extraction noextract let alloca_chacha20_poly1305: alloca_st CHACHA20_POLY1305 = fun k -> let h0 = ST.get () in let ek = B.alloca 0uy 32ul in let p = B.alloca (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; let h3 = ST.get() in B.modifies_only_not_unused_in B.loc_none h0 h3; p #pop-options inline_for_extraction noextract let alloca_aes_gcm (i: vale_impl): alloca_st (alg_of_vale_impl i) = fun k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in let ek = B.alloca 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.alloca (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in p inline_for_extraction noextract let alloca_aes128_gcm: alloca_st AES128_GCM = alloca_aes_gcm Vale_AES128 inline_for_extraction noextract let alloca_aes256_gcm: alloca_st AES256_GCM = alloca_aes_gcm Vale_AES256 let alloca #a k = match a with | AES128_GCM -> alloca_aes128_gcm k | AES256_GCM -> alloca_aes256_gcm k | CHACHA20_POLY1305 -> alloca_chacha20_poly1305 k inline_for_extraction noextract let aes_gcm_encrypt (i: vale_impl): Vale.Wrapper.X64.GCMencryptOpt.encrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMencryptOpt256.gcm256_encrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let encrypt_aes_gcm (i: vale_impl): encrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if B.is_null s then InvalidKey else let a = alg_of_vale_impl i in // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let h0 = get() in aes_gcm_encrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) plain (uint32_to_uint64 plain_len) ad (uint32_to_uint64 ad_len) tmp_iv cipher tag keys_b hkeys_b scratch_b; let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // and tag. It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 plain) in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in Seq.equal (B.as_seq h1 cipher) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat) /\ Seq.equal (B.as_seq h1 tag) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat)); pop_frame(); Success let encrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES128_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES256_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt #a s iv iv_len ad ad_len plain plain_len cipher tag = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> encrypt_aes128_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Vale_AES256 -> encrypt_aes256_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Hacl_CHACHA20 -> // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin // Length restrictions assert_norm (pow2 31 + pow2 32 / 64 <= pow2 32 - 1); EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; Success end inline_for_extraction noextract let encrypt_expand_aes_gcm (i: vale_impl): encrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = encrypt_aes_gcm i s iv iv_len ad ad_len plain plain_len cipher tag in assert(r == Success); pop_frame (); Success let encrypt_expand_aes128_gcm_no_check : encrypt_expand_st false AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes256_gcm_no_check : encrypt_expand_st false AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes128_gcm : encrypt_expand_st true AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_aes256_gcm : encrypt_expand_st true AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_chacha20_poly1305 : encrypt_expand_st false CHACHA20_POLY1305 = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s CHACHA20_POLY1305) = alloca k in let open LowStar.BufferOps in let Ek i kv ek = !*s in EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; pop_frame (); Success let encrypt_expand #a k iv iv_len ad ad_len plain plain_len cipher tag = match a with | AES128_GCM -> encrypt_expand_aes128_gcm k iv iv_len ad ad_len plain plain_len cipher tag | AES256_GCM -> encrypt_expand_aes256_gcm k iv iv_len ad ad_len plain plain_len cipher tag | CHACHA20_POLY1305 -> encrypt_expand_chacha20_poly1305 k iv iv_len ad ad_len plain plain_len cipher tag inline_for_extraction noextract let aes_gcm_decrypt (i: vale_impl): Vale.Wrapper.X64.GCMdecryptOpt.decrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMdecryptOpt.gcm128_decrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMdecryptOpt256.gcm256_decrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let decrypt_aes_gcm (i: vale_impl): decrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let a = alg_of_vale_impl i in let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let r = aes_gcm_decrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) cipher (uint32_to_uint64 cipher_len) ad (uint32_to_uint64 ad_len) tmp_iv dst tag keys_b hkeys_b scratch_b in let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let cipher_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 cipher) in let tag_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 tag) in let plain_nat, success = Vale.AES.GCM_s.gcm_decrypt_LE (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat in Seq.equal (B.as_seq h1 dst) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 plain_nat) /\ (UInt64.v r = 0) == success); assert ( let kv = G.reveal kv in let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in Seq.equal (Seq.slice cipher_tag (S.length cipher_tag - tag_length a) (S.length cipher_tag)) (B.as_seq h0 tag) /\ Seq.equal (Seq.slice cipher_tag 0 (S.length cipher_tag - tag_length a)) (B.as_seq h0 cipher)); pop_frame(); if r = 0uL then Success else AuthenticationFailure let decrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): decrypt_st AES128_GCM = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len cipher cipher_len tag dst else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let decrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): decrypt_st AES256_GCM = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len cipher cipher_len tag dst else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let decrypt_chacha20_poly1305 : decrypt_st CHACHA20_POLY1305 = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin let open LowStar.BufferOps in let Ek i kv ek = !*s in [@ inline_let ] let bound = pow2 32 - 1 - 16 in assert (v cipher_len <= bound); assert_norm (bound + 16 <= pow2 32 - 1); assert_norm (pow2 31 + bound / 64 <= pow2 32 - 1); let h0 = ST.get () in let r = EverCrypt.Chacha20Poly1305.aead_decrypt ek iv ad_len ad cipher_len dst cipher tag in assert ( let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in let tag_s = S.slice cipher_tag (S.length cipher_tag - tag_length CHACHA20_POLY1305) (S.length cipher_tag) in let cipher_s = S.slice cipher_tag 0 (S.length cipher_tag - tag_length CHACHA20_POLY1305) in S.equal cipher_s (B.as_seq h0 cipher) /\ S.equal tag_s (B.as_seq h0 tag)); if r = 0ul then Success else AuthenticationFailure end let decrypt #a s iv iv_len ad ad_len cipher cipher_len tag dst = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> decrypt_aes128_gcm () s iv iv_len ad ad_len cipher cipher_len tag dst | Vale_AES256 -> decrypt_aes256_gcm () s iv iv_len ad ad_len cipher cipher_len tag dst | Hacl_CHACHA20 -> decrypt_chacha20_poly1305 s iv iv_len ad ad_len cipher cipher_len tag dst
{ "checked_file": "/", "dependencies": [ "Vale.Wrapper.X64.GCMencryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMencryptOpt.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt.fsti.checked", "Vale.Wrapper.X64.GCM_IV.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Agile.AEAD.fst.checked", "Spec.Agile.AEAD.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.Chacha20Poly1305.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AEAD.fst" }
[ { "abbrev": false, "full_module": "EverCrypt.CTR.Keys", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher.Expansion", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "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": 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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: EverCrypt.CTR.Keys.vale_impl -> EverCrypt.AEAD.decrypt_expand_st false (EverCrypt.AEAD.alg_of_vale_impl i)
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.CTR.Keys.vale_impl", "LowStar.Buffer.buffer", "EverCrypt.CTR.Keys.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "EverCrypt.AEAD.alg_of_vale_impl", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "FStar.Integers.op_Greater", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.cipher_p", "Spec.Agile.AEAD.tag_length", "Prims.nat", "EverCrypt.Error.error_code", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "EverCrypt.AEAD.decrypt_aes_gcm", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.state_s", "EverCrypt.AEAD.alloca", "LowStar.Buffer.pointer", "FStar.HyperStack.ST.push_frame", "EverCrypt.AEAD.decrypt_expand_st" ]
[]
false
false
false
false
false
let decrypt_expand_aes_gcm (i: vale_impl) : decrypt_expand_st false (alg_of_vale_impl i) =
fun k iv iv_len ad ad_len cipher cipher_len tag dst -> push_frame (); let s:B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = decrypt_aes_gcm i s iv iv_len ad ad_len cipher cipher_len tag dst in pop_frame (); r
false
EverCrypt.AEAD.fst
EverCrypt.AEAD.decrypt_expand_chacha20_poly1305
val decrypt_expand_chacha20_poly1305: decrypt_expand_st false CHACHA20_POLY1305
val decrypt_expand_chacha20_poly1305: decrypt_expand_st false CHACHA20_POLY1305
let decrypt_expand_chacha20_poly1305 : decrypt_expand_st false CHACHA20_POLY1305 = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s CHACHA20_POLY1305) = alloca k in let r = decrypt_chacha20_poly1305 s iv iv_len ad ad_len cipher cipher_len tag dst in pop_frame (); r
{ "file_name": "providers/evercrypt/fst/EverCrypt.AEAD.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 681, "start_col": 0, "start_line": 674 }
module EverCrypt.AEAD module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open FStar.Int.Cast open Spec.Agile.AEAD open Spec.Cipher.Expansion open EverCrypt.CTR.Keys friend Spec.Agile.AEAD friend Spec.Cipher.Expansion friend EverCrypt.CTR.Keys #set-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0" /// Defining abstract predicates, invariants, footprint, etc. /// --------------------------------------------------------- let _: squash (inversion impl) = allow_inversion impl /// We now distinguish between an expanded key (as mandated by NIST spec) and a /// **concrete** expanded key, which may contain implementation-specific details /// and extra precomputations. In the rest of this module, we rely on concrete /// expanded keys, which are parameterized over an implementation, instead of /// regular expanded keys, which are parameterized over an algorithm. Helpers /// allow us to move from one notion to the other. let supported_alg_of_impl (i: impl): supported_alg = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM | Hacl_CHACHA20 -> CHACHA20_POLY1305 inline_for_extraction noextract let alg_of_vale_impl (i: vale_impl) = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM noeq type state_s a = | Ek: impl:impl -> kv:G.erased (kv a) -> ek:B.buffer UInt8.t -> // concrete expanded key state_s a let invert_state_s (a: alg): Lemma (requires True) (ensures (inversion (state_s a))) [ SMTPat (state_s a) ] = allow_inversion (state_s a) let freeable_s #a (Ek _ _ ek) = B.freeable ek let footprint_s #a (Ek _ _ ek) = B.loc_addr_of_buffer ek let invariant_s #a h (Ek i kv ek) = is_supported_alg a /\ a = supported_alg_of_impl i /\ B.live h ek /\ B.length ek >= concrete_xkey_length i /\ B.as_seq h (B.gsub ek 0ul (UInt32.uint_to_t (concrete_xkey_length i))) `S.equal` concrete_expand i (G.reveal kv) /\ config_pre a /\ ( match i with | Vale_AES128 | Vale_AES256 -> // Expanded key length + precomputed stuff + scratch space (AES-GCM specific) B.length ek = vale_xkey_length (cipher_alg_of_supported_alg a) + 176 | Hacl_CHACHA20 -> B.length ek = concrete_xkey_length i) let invariant_loc_in_footprint #a s m = () let frame_invariant #a l s h0 h1 = () /// Actual stateful API /// ------------------- let alg_of_state a s = let open LowStar.BufferOps in let Ek impl _ _ = !*s in match impl with | Hacl_CHACHA20 -> CHACHA20_POLY1305 | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM let as_kv #a (Ek _ kv _) = G.reveal kv #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" let create_in_chacha20_poly1305: create_in_st CHACHA20_POLY1305 = fun r dst k -> let h0 = ST.get () in let ek = B.malloc r 0uy 32ul in let p = B.malloc r (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; B.upd dst 0ul p; let h2 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h0 h2; Success #pop-options inline_for_extraction noextract let create_in_aes_gcm (i: vale_impl): create_in_st (alg_of_vale_impl i) = fun r dst k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in if EverCrypt.TargetConfig.hacl_can_compile_vale then ( let has_aesni = EverCrypt.AutoConfig2.has_aesni () in let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then ( let ek = B.malloc r 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.malloc r (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in let open LowStar.BufferOps in dst *= p; let h3 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h2 h3; Success ) else UnsupportedAlgorithm ) else UnsupportedAlgorithm let create_in_aes128_gcm: create_in_st AES128_GCM = create_in_aes_gcm Vale_AES128 let create_in_aes256_gcm: create_in_st AES256_GCM = create_in_aes_gcm Vale_AES256 let create_in #a r dst k = match a with | AES128_GCM -> create_in_aes128_gcm r dst k | AES256_GCM -> create_in_aes256_gcm r dst k | CHACHA20_POLY1305 -> create_in_chacha20_poly1305 r dst k | _ -> UnsupportedAlgorithm #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" inline_for_extraction noextract let alloca_chacha20_poly1305: alloca_st CHACHA20_POLY1305 = fun k -> let h0 = ST.get () in let ek = B.alloca 0uy 32ul in let p = B.alloca (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; let h3 = ST.get() in B.modifies_only_not_unused_in B.loc_none h0 h3; p #pop-options inline_for_extraction noextract let alloca_aes_gcm (i: vale_impl): alloca_st (alg_of_vale_impl i) = fun k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in let ek = B.alloca 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.alloca (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in p inline_for_extraction noextract let alloca_aes128_gcm: alloca_st AES128_GCM = alloca_aes_gcm Vale_AES128 inline_for_extraction noextract let alloca_aes256_gcm: alloca_st AES256_GCM = alloca_aes_gcm Vale_AES256 let alloca #a k = match a with | AES128_GCM -> alloca_aes128_gcm k | AES256_GCM -> alloca_aes256_gcm k | CHACHA20_POLY1305 -> alloca_chacha20_poly1305 k inline_for_extraction noextract let aes_gcm_encrypt (i: vale_impl): Vale.Wrapper.X64.GCMencryptOpt.encrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMencryptOpt256.gcm256_encrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let encrypt_aes_gcm (i: vale_impl): encrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if B.is_null s then InvalidKey else let a = alg_of_vale_impl i in // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let h0 = get() in aes_gcm_encrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) plain (uint32_to_uint64 plain_len) ad (uint32_to_uint64 ad_len) tmp_iv cipher tag keys_b hkeys_b scratch_b; let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // and tag. It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 plain) in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in Seq.equal (B.as_seq h1 cipher) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat) /\ Seq.equal (B.as_seq h1 tag) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat)); pop_frame(); Success let encrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES128_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES256_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt #a s iv iv_len ad ad_len plain plain_len cipher tag = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> encrypt_aes128_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Vale_AES256 -> encrypt_aes256_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Hacl_CHACHA20 -> // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin // Length restrictions assert_norm (pow2 31 + pow2 32 / 64 <= pow2 32 - 1); EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; Success end inline_for_extraction noextract let encrypt_expand_aes_gcm (i: vale_impl): encrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = encrypt_aes_gcm i s iv iv_len ad ad_len plain plain_len cipher tag in assert(r == Success); pop_frame (); Success let encrypt_expand_aes128_gcm_no_check : encrypt_expand_st false AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes256_gcm_no_check : encrypt_expand_st false AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes128_gcm : encrypt_expand_st true AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_aes256_gcm : encrypt_expand_st true AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_chacha20_poly1305 : encrypt_expand_st false CHACHA20_POLY1305 = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s CHACHA20_POLY1305) = alloca k in let open LowStar.BufferOps in let Ek i kv ek = !*s in EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; pop_frame (); Success let encrypt_expand #a k iv iv_len ad ad_len plain plain_len cipher tag = match a with | AES128_GCM -> encrypt_expand_aes128_gcm k iv iv_len ad ad_len plain plain_len cipher tag | AES256_GCM -> encrypt_expand_aes256_gcm k iv iv_len ad ad_len plain plain_len cipher tag | CHACHA20_POLY1305 -> encrypt_expand_chacha20_poly1305 k iv iv_len ad ad_len plain plain_len cipher tag inline_for_extraction noextract let aes_gcm_decrypt (i: vale_impl): Vale.Wrapper.X64.GCMdecryptOpt.decrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMdecryptOpt.gcm128_decrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMdecryptOpt256.gcm256_decrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let decrypt_aes_gcm (i: vale_impl): decrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let a = alg_of_vale_impl i in let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let r = aes_gcm_decrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) cipher (uint32_to_uint64 cipher_len) ad (uint32_to_uint64 ad_len) tmp_iv dst tag keys_b hkeys_b scratch_b in let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let cipher_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 cipher) in let tag_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 tag) in let plain_nat, success = Vale.AES.GCM_s.gcm_decrypt_LE (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat in Seq.equal (B.as_seq h1 dst) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 plain_nat) /\ (UInt64.v r = 0) == success); assert ( let kv = G.reveal kv in let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in Seq.equal (Seq.slice cipher_tag (S.length cipher_tag - tag_length a) (S.length cipher_tag)) (B.as_seq h0 tag) /\ Seq.equal (Seq.slice cipher_tag 0 (S.length cipher_tag - tag_length a)) (B.as_seq h0 cipher)); pop_frame(); if r = 0uL then Success else AuthenticationFailure let decrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): decrypt_st AES128_GCM = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len cipher cipher_len tag dst else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let decrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): decrypt_st AES256_GCM = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len cipher cipher_len tag dst else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let decrypt_chacha20_poly1305 : decrypt_st CHACHA20_POLY1305 = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin let open LowStar.BufferOps in let Ek i kv ek = !*s in [@ inline_let ] let bound = pow2 32 - 1 - 16 in assert (v cipher_len <= bound); assert_norm (bound + 16 <= pow2 32 - 1); assert_norm (pow2 31 + bound / 64 <= pow2 32 - 1); let h0 = ST.get () in let r = EverCrypt.Chacha20Poly1305.aead_decrypt ek iv ad_len ad cipher_len dst cipher tag in assert ( let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in let tag_s = S.slice cipher_tag (S.length cipher_tag - tag_length CHACHA20_POLY1305) (S.length cipher_tag) in let cipher_s = S.slice cipher_tag 0 (S.length cipher_tag - tag_length CHACHA20_POLY1305) in S.equal cipher_s (B.as_seq h0 cipher) /\ S.equal tag_s (B.as_seq h0 tag)); if r = 0ul then Success else AuthenticationFailure end let decrypt #a s iv iv_len ad ad_len cipher cipher_len tag dst = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> decrypt_aes128_gcm () s iv iv_len ad ad_len cipher cipher_len tag dst | Vale_AES256 -> decrypt_aes256_gcm () s iv iv_len ad ad_len cipher cipher_len tag dst | Hacl_CHACHA20 -> decrypt_chacha20_poly1305 s iv iv_len ad ad_len cipher cipher_len tag dst inline_for_extraction noextract let decrypt_expand_aes_gcm (i: vale_impl): decrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = decrypt_aes_gcm i s iv iv_len ad ad_len cipher cipher_len tag dst in pop_frame (); r let decrypt_expand_aes128_gcm_no_check : decrypt_expand_st false AES128_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len cipher cipher_len tag dst else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let decrypt_expand_aes256_gcm_no_check : decrypt_expand_st false AES256_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then decrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len cipher cipher_len tag dst else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let decrypt_expand_aes128_gcm : decrypt_expand_st true AES128_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then decrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len cipher cipher_len tag dst else UnsupportedAlgorithm else UnsupportedAlgorithm let decrypt_expand_aes256_gcm : decrypt_expand_st true AES256_GCM = fun k iv iv_len ad ad_len cipher cipher_len tag dst -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then decrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len cipher cipher_len tag dst else UnsupportedAlgorithm else UnsupportedAlgorithm
{ "checked_file": "/", "dependencies": [ "Vale.Wrapper.X64.GCMencryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMencryptOpt.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt.fsti.checked", "Vale.Wrapper.X64.GCM_IV.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Agile.AEAD.fst.checked", "Spec.Agile.AEAD.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.Chacha20Poly1305.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AEAD.fst" }
[ { "abbrev": false, "full_module": "EverCrypt.CTR.Keys", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher.Expansion", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "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": 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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverCrypt.AEAD.decrypt_expand_st false Spec.Agile.AEAD.CHACHA20_POLY1305
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.buffer", "EverCrypt.CTR.Keys.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "Spec.Agile.AEAD.CHACHA20_POLY1305", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "FStar.Integers.op_Greater", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.cipher_p", "Spec.Agile.AEAD.tag_length", "Prims.nat", "EverCrypt.Error.error_code", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "EverCrypt.AEAD.decrypt_chacha20_poly1305", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.state_s", "EverCrypt.AEAD.alloca", "LowStar.Buffer.pointer", "FStar.HyperStack.ST.push_frame", "EverCrypt.AEAD.decrypt_expand_st" ]
[]
false
false
false
false
false
let decrypt_expand_chacha20_poly1305:decrypt_expand_st false CHACHA20_POLY1305 =
fun k iv iv_len ad ad_len cipher cipher_len tag dst -> push_frame (); let s:B.pointer_or_null (state_s CHACHA20_POLY1305) = alloca k in let r = decrypt_chacha20_poly1305 s iv iv_len ad ad_len cipher cipher_len tag dst in pop_frame (); r
false
Hacl.P256.PrecompTable.fst
Hacl.P256.PrecompTable.precomp_g_pow2_192_table_list_w4
val precomp_g_pow2_192_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
val precomp_g_pow2_192_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15)
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 92, "end_line": 262, "start_col": 0, "start_line": 261 }
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)]
{ "checked_file": "/", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) {FStar.List.Tot.Base.length x = 192}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_192" ]
[]
false
false
false
false
false
let precomp_g_pow2_192_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15)
false
SteelTableJoin.fst
SteelTableJoin.v3
val v3 (#pl #pr: Ghost.erased nat) (al ar err: ptr) : STT unit (((pts_to1 al pl) `star` (pts_to1 ar pr)) `star` (exists_ (fun v -> pts_to1 err v))) (fun _ -> exists_ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v))))
val v3 (#pl #pr: Ghost.erased nat) (al ar err: ptr) : STT unit (((pts_to1 al pl) `star` (pts_to1 ar pr)) `star` (exists_ (fun v -> pts_to1 err v))) (fun _ -> exists_ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v))))
let v3 (#pl #pr: Ghost.erased nat) (al: ptr) (ar: ptr) (err: ptr) : STT unit (pts_to1 al pl `star` pts_to1 ar pr `star` exists_ (fun v -> pts_to1 err v)) (fun _ -> exists_ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v))) = let _ = gen_elim () in let _ = join al ar in // let _ = gen_elim () in // assert_ (exists_ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v))); noop ()
{ "file_name": "share/steel/tests/SteelTableJoin.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 9, "end_line": 63, "start_col": 0, "start_line": 56 }
module SteelTableJoin open Steel.ST.GenElim assume val ptr : Type0 assume val pts_to1 (p: ptr) (v: Ghost.erased nat) : vprop assume val split (#v: Ghost.erased nat) (p: ptr) : STT ptr (pts_to1 p v) (fun res -> exists_ (fun vl -> exists_ (fun vr -> pts_to1 p vl `star` pts_to1 res vr))) assume val join (#opened: _) (#pl #pr: Ghost.erased nat) (al ar: ptr) : STGhostT (Ghost.erased nat) opened (pts_to1 al pl `star` pts_to1 ar pr) (fun res -> pts_to1 al res) assume val v1 (#p: Ghost.erased nat) (a: ptr) (err: ptr) : STT unit (pts_to1 a p `star` pts_to1 err 0) (fun _ -> pts_to1 a p `star` exists_ (fun v -> pts_to1 err v)) let v2 (#p: Ghost.erased nat) (al: ptr) (err: ptr) : STT unit (pts_to1 al p `star` pts_to1 err 0) (fun _ -> exists_ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v))) = let ar = split al in let _ = gen_elim () in let _ = v1 ar err in let _ = gen_elim () in let _ = join al ar in intro_exists _ (fun v -> pts_to1 al _ `star` pts_to1 err v); intro_exists _ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v)); return () let v2' (#p: Ghost.erased nat) (al: ptr) (err: ptr) : STT unit (pts_to1 al p `star` pts_to1 err 0) (fun _ -> exists_ (fun p -> exists_ (fun v -> pts_to1 al p `star` pts_to1 err v))) = let ar = split al in let _ = gen_elim () in let _ = v1 ar err in let _ = elim_exists () in // let _ = elim_pure _ in let _ = noop () in let _ = join al ar in return () #set-options "--print_implicits" assume val noop_f (#opened: _) (#p: vprop) (_: unit) : STGhostF unit opened p (fun _ -> p) True (fun _ -> True) #set-options "--print_full_names"
{ "checked_file": "/", "dependencies": [ "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "SteelTableJoin.fst" }
[ { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
al: SteelTableJoin.ptr -> ar: SteelTableJoin.ptr -> err: SteelTableJoin.ptr -> Steel.ST.Effect.STT Prims.unit
Steel.ST.Effect.STT
[]
[]
[ "FStar.Ghost.erased", "Prims.nat", "SteelTableJoin.ptr", "Steel.ST.Util.noop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.unit", "SteelTableJoin.join", "Steel.ST.GenElim.gen_elim", "Steel.Effect.Common.VStar", "Steel.ST.Util.exists_", "SteelTableJoin.pts_to1", "Steel.Effect.Common.vprop", "Steel.Effect.Common.star", "FStar.Ghost.reveal", "Prims.l_and", "Prims.l_True", "Prims.prop" ]
[]
false
true
false
false
false
let v3 (#pl #pr: Ghost.erased nat) (al ar err: ptr) : STT unit (((pts_to1 al pl) `star` (pts_to1 ar pr)) `star` (exists_ (fun v -> pts_to1 err v))) (fun _ -> exists_ (fun p -> exists_ (fun v -> (pts_to1 al p) `star` (pts_to1 err v)))) =
let _ = gen_elim () in let _ = join al ar in noop ()
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.to_id
val to_id (n:nat{n < size}) : id
val to_id (n:nat{n < size}) : id
let to_id (n:nat{n < size}) : id = n
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 28, "start_col": 0, "start_line": 28 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
n: Prims.nat{n < FStar.DM4F.Heap.Random.size} -> FStar.DM4F.Heap.Random.id
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.DM4F.Heap.Random.size", "FStar.DM4F.Heap.Random.id" ]
[]
false
false
false
false
false
let to_id (n: nat{n < size}) : id =
n
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.incrementable
val incrementable: id -> bool
val incrementable: id -> bool
let incrementable (i:id) = i + 1 < size
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 30, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
i: FStar.DM4F.Heap.Random.id -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.Random.id", "Prims.op_LessThan", "Prims.op_Addition", "FStar.DM4F.Heap.Random.size", "Prims.bool" ]
[]
false
false
false
true
false
let incrementable (i: id) =
i + 1 < size
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.equal
val equal: tape -> tape -> GTot Type0
val equal: tape -> tape -> GTot Type0
let equal (t1:tape) (t2:tape) = Seq.equal t1 t2
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 40, "start_col": 0, "start_line": 40 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n let incrementable (i:id) = i + 1 < size let incr (i:id{incrementable i}) : id = to_id (i + 1) let index (h:tape) (i:id) : Tot elem = index h i let upd (h:tape) (i:id) (x:elem) : Tot tape = upd h i x let create (x:elem) : Tot tape = create #elem size x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
t1: FStar.DM4F.Heap.Random.tape -> t2: FStar.DM4F.Heap.Random.tape -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.DM4F.Heap.Random.tape", "FStar.Seq.Base.equal", "FStar.DM4F.Heap.Random.elem" ]
[]
false
false
false
false
true
let equal (t1 t2: tape) =
Seq.equal t1 t2
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.incr
val incr (i:id{incrementable i}) : id
val incr (i:id{incrementable i}) : id
let incr (i:id{incrementable i}) : id = to_id (i + 1)
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 32, "start_col": 0, "start_line": 32 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n let incrementable (i:id) = i + 1 < size
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
i: FStar.DM4F.Heap.Random.id{FStar.DM4F.Heap.Random.incrementable i} -> FStar.DM4F.Heap.Random.id
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.Random.id", "Prims.b2t", "FStar.DM4F.Heap.Random.incrementable", "FStar.DM4F.Heap.Random.to_id", "Prims.op_Addition" ]
[]
false
false
false
false
false
let incr (i: id{incrementable i}) : id =
to_id (i + 1)
false
FStar.Monotonic.Pure.fst
FStar.Monotonic.Pure.is_monotonic
val is_monotonic : wp: Prims.pure_wp' a -> Prims.logical
let is_monotonic (#a:Type) (wp:pure_wp' a) = (* * Once we support using tactics in ulib/, * this would be written as: Prims.pure_wp_monotonic0, * with a postprocessing tactic to norm it *) forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
{ "file_name": "ulib/FStar.Monotonic.Pure.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 75, "end_line": 34, "start_col": 0, "start_line": 28 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Monotonic.Pure (* * This module provides utilities to intro and elim the monotonicity * property of pure wps * * Since pure_wp_monotonic predicate is marked opaque_to_smt in prims, * reasoning with it requires explicit coercions *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Pure.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.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
wp: Prims.pure_wp' a -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.pure_wp'", "Prims.l_Forall", "Prims.pure_post", "Prims.l_imp", "Prims.logical" ]
[]
false
false
false
true
true
let is_monotonic (#a: Type) (wp: pure_wp' a) =
forall (p: pure_post a) (q: pure_post a). (forall (x: a). p x ==> q x) ==> (wp p ==> wp q)
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.upd
val upd (h:tape) (i:id) (x:elem) : Tot tape
val upd (h:tape) (i:id) (x:elem) : Tot tape
let upd (h:tape) (i:id) (x:elem) : Tot tape = upd h i x
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 55, "end_line": 36, "start_col": 0, "start_line": 36 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n let incrementable (i:id) = i + 1 < size let incr (i:id{incrementable i}) : id = to_id (i + 1) let index (h:tape) (i:id) : Tot elem = index h i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.DM4F.Heap.Random.tape -> i: FStar.DM4F.Heap.Random.id -> x: FStar.DM4F.Heap.Random.elem -> FStar.DM4F.Heap.Random.tape
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.Random.tape", "FStar.DM4F.Heap.Random.id", "FStar.DM4F.Heap.Random.elem", "FStar.Seq.Base.upd" ]
[]
false
false
false
true
false
let upd (h: tape) (i: id) (x: elem) : Tot tape =
upd h i x
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.index
val index (h:tape) (i:id) : Tot elem
val index (h:tape) (i:id) : Tot elem
let index (h:tape) (i:id) : Tot elem = index h i
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 34, "start_col": 0, "start_line": 34 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n let incrementable (i:id) = i + 1 < size let incr (i:id{incrementable i}) : id = to_id (i + 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.DM4F.Heap.Random.tape -> i: FStar.DM4F.Heap.Random.id -> FStar.DM4F.Heap.Random.elem
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.Random.tape", "FStar.DM4F.Heap.Random.id", "FStar.Seq.Base.index", "FStar.DM4F.Heap.Random.elem" ]
[]
false
false
false
true
false
let index (h: tape) (i: id) : Tot elem =
index h i
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.create
val create (x:elem) : Tot tape
val create (x:elem) : Tot tape
let create (x:elem) : Tot tape = create #elem size x
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 52, "end_line": 38, "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 FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n let incrementable (i:id) = i + 1 < size let incr (i:id{incrementable i}) : id = to_id (i + 1) let index (h:tape) (i:id) : Tot elem = index h i let upd (h:tape) (i:id) (x:elem) : Tot tape = upd h i x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.DM4F.Heap.Random.elem -> FStar.DM4F.Heap.Random.tape
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.Random.elem", "FStar.Seq.Base.create", "FStar.DM4F.Heap.Random.size", "FStar.DM4F.Heap.Random.tape" ]
[]
false
false
false
true
false
let create (x: elem) : Tot tape =
create #elem size x
false
FStar.Monotonic.Pure.fst
FStar.Monotonic.Pure.elim_pure_wp_monotonicity
val elim_pure_wp_monotonicity (#a: Type) (wp: pure_wp a) : Lemma (is_monotonic wp)
val elim_pure_wp_monotonicity (#a: Type) (wp: pure_wp a) : Lemma (is_monotonic wp)
let elim_pure_wp_monotonicity (#a:Type) (wp:pure_wp a) : Lemma (is_monotonic wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic
{ "file_name": "ulib/FStar.Monotonic.Pure.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 38, "start_col": 0, "start_line": 36 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Monotonic.Pure (* * This module provides utilities to intro and elim the monotonicity * property of pure wps * * Since pure_wp_monotonic predicate is marked opaque_to_smt in prims, * reasoning with it requires explicit coercions *) unfold let is_monotonic (#a:Type) (wp:pure_wp' a) = (* * Once we support using tactics in ulib/, * this would be written as: Prims.pure_wp_monotonic0, * with a postprocessing tactic to norm it *) forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Pure.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.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
wp: Prims.pure_wp a -> FStar.Pervasives.Lemma (ensures FStar.Monotonic.Pure.is_monotonic wp)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pure_wp", "FStar.Pervasives.reveal_opaque", "Prims.pure_wp'", "Prims.logical", "Prims.pure_wp_monotonic", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Monotonic.Pure.is_monotonic", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let elim_pure_wp_monotonicity (#a: Type) (wp: pure_wp a) : Lemma (is_monotonic wp) =
reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.lemma_index_upd2
val lemma_index_upd2: s:tape -> n:id -> v:elem -> i:id{i<>n} -> Lemma (requires True) (ensures (index (upd s n v) i == index s i)) [SMTPat (index (upd s n v) i)]
val lemma_index_upd2: s:tape -> n:id -> v:elem -> i:id{i<>n} -> Lemma (requires True) (ensures (index (upd s n v) i == index s i)) [SMTPat (index (upd s n v) i)]
let lemma_index_upd2 s n v i = lemma_index_upd2 #elem s n v i
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 51, "start_col": 0, "start_line": 51 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n let incrementable (i:id) = i + 1 < size let incr (i:id{incrementable i}) : id = to_id (i + 1) let index (h:tape) (i:id) : Tot elem = index h i let upd (h:tape) (i:id) (x:elem) : Tot tape = upd h i x let create (x:elem) : Tot tape = create #elem size x let equal (t1:tape) (t2:tape) = Seq.equal t1 t2 let lemma_eq_intro s1 s2 = assert (forall (i:id). index s1 i == Seq.index s1 i); assert (forall (i:id). index s2 i == Seq.index s2 i); Seq.lemma_eq_intro #elem s1 s2 let lemma_eq_elim s1 s2 = () let lemma_index_upd1 s n v = lemma_index_upd1 #elem s n v
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.DM4F.Heap.Random.tape -> n: FStar.DM4F.Heap.Random.id -> v: FStar.DM4F.Heap.Random.elem -> i: FStar.DM4F.Heap.Random.id{i <> n} -> FStar.Pervasives.Lemma (ensures FStar.DM4F.Heap.Random.index (FStar.DM4F.Heap.Random.upd s n v) i == FStar.DM4F.Heap.Random.index s i) [SMTPat (FStar.DM4F.Heap.Random.index (FStar.DM4F.Heap.Random.upd s n v) i)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.DM4F.Heap.Random.tape", "FStar.DM4F.Heap.Random.id", "FStar.DM4F.Heap.Random.elem", "Prims.b2t", "Prims.op_disEquality", "FStar.Seq.Base.lemma_index_upd2", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_index_upd2 s n v i =
lemma_index_upd2 #elem s n v i
false
FStar.Monotonic.Pure.fst
FStar.Monotonic.Pure.intro_pure_wp_monotonicity
val intro_pure_wp_monotonicity (#a: Type) (wp: pure_wp' a) : Lemma (requires is_monotonic wp) (ensures pure_wp_monotonic a wp)
val intro_pure_wp_monotonicity (#a: Type) (wp: pure_wp' a) : Lemma (requires is_monotonic wp) (ensures pure_wp_monotonic a wp)
let intro_pure_wp_monotonicity (#a:Type) (wp:pure_wp' a) : Lemma (requires is_monotonic wp) (ensures pure_wp_monotonic a wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic
{ "file_name": "ulib/FStar.Monotonic.Pure.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 49, "start_col": 0, "start_line": 45 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Monotonic.Pure (* * This module provides utilities to intro and elim the monotonicity * property of pure wps * * Since pure_wp_monotonic predicate is marked opaque_to_smt in prims, * reasoning with it requires explicit coercions *) unfold let is_monotonic (#a:Type) (wp:pure_wp' a) = (* * Once we support using tactics in ulib/, * this would be written as: Prims.pure_wp_monotonic0, * with a postprocessing tactic to norm it *) forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q) let elim_pure_wp_monotonicity (#a:Type) (wp:pure_wp a) : Lemma (is_monotonic wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic let elim_pure_wp_monotonicity_forall (_:unit) : Lemma (forall (a:Type) (wp:pure_wp a). is_monotonic wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Pure.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.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
wp: Prims.pure_wp' a -> FStar.Pervasives.Lemma (requires FStar.Monotonic.Pure.is_monotonic wp) (ensures Prims.pure_wp_monotonic a wp)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pure_wp'", "FStar.Pervasives.reveal_opaque", "Prims.logical", "Prims.pure_wp_monotonic", "Prims.unit", "FStar.Monotonic.Pure.is_monotonic", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let intro_pure_wp_monotonicity (#a: Type) (wp: pure_wp' a) : Lemma (requires is_monotonic wp) (ensures pure_wp_monotonic a wp) =
reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.lemma_index_upd1
val lemma_index_upd1: s:tape -> n:id -> v:elem -> Lemma (requires True) (ensures (index (upd s n v) n == v)) [SMTPat (index (upd s n v) n)]
val lemma_index_upd1: s:tape -> n:id -> v:elem -> Lemma (requires True) (ensures (index (upd s n v) n == v)) [SMTPat (index (upd s n v) n)]
let lemma_index_upd1 s n v = lemma_index_upd1 #elem s n v
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 49, "start_col": 0, "start_line": 49 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n let incrementable (i:id) = i + 1 < size let incr (i:id{incrementable i}) : id = to_id (i + 1) let index (h:tape) (i:id) : Tot elem = index h i let upd (h:tape) (i:id) (x:elem) : Tot tape = upd h i x let create (x:elem) : Tot tape = create #elem size x let equal (t1:tape) (t2:tape) = Seq.equal t1 t2 let lemma_eq_intro s1 s2 = assert (forall (i:id). index s1 i == Seq.index s1 i); assert (forall (i:id). index s2 i == Seq.index s2 i); Seq.lemma_eq_intro #elem s1 s2 let lemma_eq_elim s1 s2 = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.DM4F.Heap.Random.tape -> n: FStar.DM4F.Heap.Random.id -> v: FStar.DM4F.Heap.Random.elem -> FStar.Pervasives.Lemma (ensures FStar.DM4F.Heap.Random.index (FStar.DM4F.Heap.Random.upd s n v) n == v) [SMTPat (FStar.DM4F.Heap.Random.index (FStar.DM4F.Heap.Random.upd s n v) n)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.DM4F.Heap.Random.tape", "FStar.DM4F.Heap.Random.id", "FStar.DM4F.Heap.Random.elem", "FStar.Seq.Base.lemma_index_upd1", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_index_upd1 s n v =
lemma_index_upd1 #elem s n v
false
FStar.Monotonic.Pure.fst
FStar.Monotonic.Pure.as_pure_wp
val as_pure_wp (#a: Type) (wp: pure_wp' a) : Pure (pure_wp a) (requires is_monotonic wp) (ensures fun r -> r == wp)
val as_pure_wp (#a: Type) (wp: pure_wp' a) : Pure (pure_wp a) (requires is_monotonic wp) (ensures fun r -> r == wp)
let as_pure_wp (#a:Type) (wp:pure_wp' a) : Pure (pure_wp a) (requires is_monotonic wp) (ensures fun r -> r == wp) = intro_pure_wp_monotonicity wp; wp
{ "file_name": "ulib/FStar.Monotonic.Pure.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 57, "start_col": 0, "start_line": 52 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Monotonic.Pure (* * This module provides utilities to intro and elim the monotonicity * property of pure wps * * Since pure_wp_monotonic predicate is marked opaque_to_smt in prims, * reasoning with it requires explicit coercions *) unfold let is_monotonic (#a:Type) (wp:pure_wp' a) = (* * Once we support using tactics in ulib/, * this would be written as: Prims.pure_wp_monotonic0, * with a postprocessing tactic to norm it *) forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q) let elim_pure_wp_monotonicity (#a:Type) (wp:pure_wp a) : Lemma (is_monotonic wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic let elim_pure_wp_monotonicity_forall (_:unit) : Lemma (forall (a:Type) (wp:pure_wp a). is_monotonic wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic let intro_pure_wp_monotonicity (#a:Type) (wp:pure_wp' a) : Lemma (requires is_monotonic wp) (ensures pure_wp_monotonic a wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Pure.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.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
wp: Prims.pure_wp' a -> Prims.Pure (Prims.pure_wp a)
Prims.Pure
[]
[]
[ "Prims.pure_wp'", "Prims.unit", "FStar.Monotonic.Pure.intro_pure_wp_monotonicity", "Prims.pure_wp", "FStar.Monotonic.Pure.is_monotonic", "Prims.eq2" ]
[]
false
false
false
false
false
let as_pure_wp (#a: Type) (wp: pure_wp' a) : Pure (pure_wp a) (requires is_monotonic wp) (ensures fun r -> r == wp) =
intro_pure_wp_monotonicity wp; wp
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.lemma_eq_intro
val lemma_eq_intro: s1:tape -> s2:tape -> Lemma (requires ((forall (i:id).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i))) (ensures (equal s1 s2)) [SMTPat (equal s1 s2)]
val lemma_eq_intro: s1:tape -> s2:tape -> Lemma (requires ((forall (i:id).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i))) (ensures (equal s1 s2)) [SMTPat (equal s1 s2)]
let lemma_eq_intro s1 s2 = assert (forall (i:id). index s1 i == Seq.index s1 i); assert (forall (i:id). index s2 i == Seq.index s2 i); Seq.lemma_eq_intro #elem s1 s2
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 45, "start_col": 0, "start_line": 42 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n let incrementable (i:id) = i + 1 < size let incr (i:id{incrementable i}) : id = to_id (i + 1) let index (h:tape) (i:id) : Tot elem = index h i let upd (h:tape) (i:id) (x:elem) : Tot tape = upd h i x let create (x:elem) : Tot tape = create #elem size x let equal (t1:tape) (t2:tape) = Seq.equal t1 t2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: FStar.DM4F.Heap.Random.tape -> s2: FStar.DM4F.Heap.Random.tape -> FStar.Pervasives.Lemma (requires forall (i: FStar.DM4F.Heap.Random.id). {:pattern FStar.DM4F.Heap.Random.index s1 i; FStar.DM4F.Heap.Random.index s2 i} FStar.DM4F.Heap.Random.index s1 i == FStar.DM4F.Heap.Random.index s2 i) (ensures FStar.DM4F.Heap.Random.equal s1 s2) [SMTPat (FStar.DM4F.Heap.Random.equal s1 s2)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.DM4F.Heap.Random.tape", "FStar.Seq.Base.lemma_eq_intro", "FStar.DM4F.Heap.Random.elem", "Prims.unit", "Prims._assert", "Prims.l_Forall", "FStar.DM4F.Heap.Random.id", "Prims.eq2", "FStar.DM4F.Heap.Random.index", "FStar.Seq.Base.index" ]
[]
false
false
true
false
false
let lemma_eq_intro s1 s2 =
assert (forall (i: id). index s1 i == Seq.index s1 i); assert (forall (i: id). index s2 i == Seq.index s2 i); Seq.lemma_eq_intro #elem s1 s2
false
FStar.Monotonic.Pure.fst
FStar.Monotonic.Pure.elim_pure_wp_monotonicity_forall
val elim_pure_wp_monotonicity_forall: unit -> Lemma (forall (a: Type) (wp: pure_wp a). is_monotonic wp)
val elim_pure_wp_monotonicity_forall: unit -> Lemma (forall (a: Type) (wp: pure_wp a). is_monotonic wp)
let elim_pure_wp_monotonicity_forall (_:unit) : Lemma (forall (a:Type) (wp:pure_wp a). is_monotonic wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic
{ "file_name": "ulib/FStar.Monotonic.Pure.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 43, "start_col": 0, "start_line": 40 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Monotonic.Pure (* * This module provides utilities to intro and elim the monotonicity * property of pure wps * * Since pure_wp_monotonic predicate is marked opaque_to_smt in prims, * reasoning with it requires explicit coercions *) unfold let is_monotonic (#a:Type) (wp:pure_wp' a) = (* * Once we support using tactics in ulib/, * this would be written as: Prims.pure_wp_monotonic0, * with a postprocessing tactic to norm it *) forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q) let elim_pure_wp_monotonicity (#a:Type) (wp:pure_wp a) : Lemma (is_monotonic wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Pure.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (a: Type) (wp: Prims.pure_wp a). FStar.Monotonic.Pure.is_monotonic wp)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "FStar.Pervasives.reveal_opaque", "Prims.pure_wp'", "Prims.logical", "Prims.pure_wp_monotonic", "Prims.l_True", "Prims.squash", "Prims.l_Forall", "Prims.pure_wp", "FStar.Monotonic.Pure.is_monotonic", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let elim_pure_wp_monotonicity_forall (_: unit) : Lemma (forall (a: Type) (wp: pure_wp a). is_monotonic wp) =
reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic
false
FStar.DM4F.Heap.Random.fst
FStar.DM4F.Heap.Random.lemma_index_create
val lemma_index_create: v:elem -> i:id -> Lemma (requires True) (ensures (index (create v) i == v)) [SMTPat (index (create v) i)]
val lemma_index_create: v:elem -> i:id -> Lemma (requires True) (ensures (index (create v) i == v)) [SMTPat (index (create v) i)]
let lemma_index_create v i = lemma_index_create #elem size v i
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.Random.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 53, "start_col": 0, "start_line": 53 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap.Random (***** Random tape *****) open FStar.Seq let q = admit () type id = i:nat{i < size} type tape = h:seq elem{length h == size} let to_id (n:nat{n < size}) : id = n let incrementable (i:id) = i + 1 < size let incr (i:id{incrementable i}) : id = to_id (i + 1) let index (h:tape) (i:id) : Tot elem = index h i let upd (h:tape) (i:id) (x:elem) : Tot tape = upd h i x let create (x:elem) : Tot tape = create #elem size x let equal (t1:tape) (t2:tape) = Seq.equal t1 t2 let lemma_eq_intro s1 s2 = assert (forall (i:id). index s1 i == Seq.index s1 i); assert (forall (i:id). index s2 i == Seq.index s2 i); Seq.lemma_eq_intro #elem s1 s2 let lemma_eq_elim s1 s2 = () let lemma_index_upd1 s n v = lemma_index_upd1 #elem s n v let lemma_index_upd2 s n v i = lemma_index_upd2 #elem s n v i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.Random.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
v: FStar.DM4F.Heap.Random.elem -> i: FStar.DM4F.Heap.Random.id -> FStar.Pervasives.Lemma (ensures FStar.DM4F.Heap.Random.index (FStar.DM4F.Heap.Random.create v) i == v) [SMTPat (FStar.DM4F.Heap.Random.index (FStar.DM4F.Heap.Random.create v) i)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.DM4F.Heap.Random.elem", "FStar.DM4F.Heap.Random.id", "FStar.Seq.Base.lemma_index_create", "FStar.DM4F.Heap.Random.size", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_index_create v i =
lemma_index_create #elem size v i
false
FStar.Monotonic.Pure.fst
FStar.Monotonic.Pure.elim_pure
val elim_pure (#a: Type) (#wp: pure_wp a) ($f: (unit -> PURE a wp)) (p: pure_post a) : Pure a (requires (wp p)) (ensures (fun r -> p r))
val elim_pure (#a: Type) (#wp: pure_wp a) ($f: (unit -> PURE a wp)) (p: pure_post a) : Pure a (requires (wp p)) (ensures (fun r -> p r))
let elim_pure (#a:Type) (#wp:pure_wp a) ($f : unit -> PURE a wp) (p:pure_post a) : Pure a (requires (wp p)) (ensures (fun r -> p r)) = elim_pure_wp_monotonicity wp; f ()
{ "file_name": "ulib/FStar.Monotonic.Pure.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 8, "end_line": 62, "start_col": 0, "start_line": 59 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Monotonic.Pure (* * This module provides utilities to intro and elim the monotonicity * property of pure wps * * Since pure_wp_monotonic predicate is marked opaque_to_smt in prims, * reasoning with it requires explicit coercions *) unfold let is_monotonic (#a:Type) (wp:pure_wp' a) = (* * Once we support using tactics in ulib/, * this would be written as: Prims.pure_wp_monotonic0, * with a postprocessing tactic to norm it *) forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q) let elim_pure_wp_monotonicity (#a:Type) (wp:pure_wp a) : Lemma (is_monotonic wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic let elim_pure_wp_monotonicity_forall (_:unit) : Lemma (forall (a:Type) (wp:pure_wp a). is_monotonic wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic let intro_pure_wp_monotonicity (#a:Type) (wp:pure_wp' a) : Lemma (requires is_monotonic wp) (ensures pure_wp_monotonic a wp) = reveal_opaque (`%pure_wp_monotonic) pure_wp_monotonic unfold let as_pure_wp (#a:Type) (wp:pure_wp' a) : Pure (pure_wp a) (requires is_monotonic wp) (ensures fun r -> r == wp) = intro_pure_wp_monotonicity wp; wp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Pure.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.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
$f: (_: Prims.unit -> Prims.PURE a) -> p: Prims.pure_post a -> Prims.Pure a
Prims.Pure
[]
[]
[ "Prims.pure_wp", "Prims.unit", "Prims.pure_post", "FStar.Monotonic.Pure.elim_pure_wp_monotonicity" ]
[]
false
false
false
false
false
let elim_pure (#a: Type) (#wp: pure_wp a) ($f: (unit -> PURE a wp)) (p: pure_post a) : Pure a (requires (wp p)) (ensures (fun r -> p r)) =
elim_pure_wp_monotonicity wp; f ()
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.addr_of
val addr_of: #a:Type -> ref a -> Tot nat
val addr_of: #a:Type -> ref a -> Tot nat
let addr_of #a r = r.addr
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 38, "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 FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
r: FStar.DM4F.Heap.ref a -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.ref", "FStar.DM4F.Heap.__proj__Mkref__item__addr", "Prims.nat" ]
[]
false
false
false
true
false
let addr_of #a r =
r.addr
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.consistent
val consistent : h0: FStar.DM4F.Heap.heap -> h1: FStar.DM4F.Heap.heap -> Prims.logical
let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 83, "end_line": 31, "start_col": 8, "start_line": 30 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
h0: FStar.DM4F.Heap.heap -> h1: FStar.DM4F.Heap.heap -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.heap", "Prims.l_Forall", "Prims.nat", "Prims.dtuple2", "Prims.l_imp", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__memory", "FStar.Pervasives.Native.Some", "FStar.Pervasives.dfst", "Prims.logical" ]
[]
false
false
false
true
true
let consistent (h0 h1: heap) =
forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.contains_a_well_typed
val contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) : Type0
val contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) : Type0
let contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) = Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 66, "end_line": 43, "start_col": 0, "start_line": 42 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr let compare_addrs #a #b r1 r2 = r1.addr = r2.addr
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.DM4F.Heap.heap -> r: FStar.DM4F.Heap.ref a -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.ref", "Prims.l_and", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "Prims.dtuple2", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__memory", "FStar.DM4F.Heap.__proj__Mkref__item__addr", "Prims.eq2", "FStar.Pervasives.dfst", "FStar.Pervasives.Native.__proj__Some__item__v" ]
[]
false
false
false
true
true
let contains_a_well_typed (#a: Type0) (h: heap) (r: ref a) =
Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.contains
val contains (#a:Type) (h:heap) (r:ref a): Tot Type0
val contains (#a:Type) (h:heap) (r:ref a): Tot Type0
let contains (#a:Type) (h:heap) (r:ref a): Tot Type0 = Some? (h.memory r.addr)
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 78, "end_line": 90, "start_col": 0, "start_line": 90 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr let compare_addrs #a #b r1 r2 = r1.addr = r2.addr let contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) = Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a (* exists (x:a). h.memory r.addr == Some (| a, x |) *) (* Select. *) let sel_tot #a h r = match h.memory r.addr with | Some (| _ , x |) -> x let sel #a h r = if FStar.StrongExcludedMiddle.strong_excluded_middle (h `contains_a_well_typed` r) then sel_tot #a h r else r.init (* Update. *) let upd_tot #a h0 r x = { h0 with memory = F.on_dom nat (fun r' -> if r.addr = r' then Some (| a, x |) else h0.memory r') } let upd #a h0 r x = if FStar.StrongExcludedMiddle.strong_excluded_middle (h0 `contains_a_well_typed` r) then upd_tot h0 r x else if r.addr >= h0.next_addr then (* alloc at r.addr *) { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r':nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } else (* type modifying update at r.addr *) { h0 with memory = F.on_dom nat (fun r' -> if r' = r.addr then Some (| a, x |) else h0.memory r') } (* Generating a fresh reference for the given heap. *) let alloc #a h0 x = let r = { addr = h0.next_addr; init = x } in let h1 = { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r':nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } in assert (let h2 = upd h0 r x in FStar.FunctionalExtensionality.feq h1.memory h2.memory); r, h1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.DM4F.Heap.heap -> r: FStar.DM4F.Heap.ref a -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.ref", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "Prims.dtuple2", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__memory", "FStar.DM4F.Heap.__proj__Mkref__item__addr" ]
[]
false
false
false
true
true
let contains (#a: Type) (h: heap) (r: ref a) : Tot Type0 =
Some? (h.memory r.addr)
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.sel_tot
val sel_tot : #a:Type -> h:heap -> r:ref a{h `contains_a_well_typed` r} -> Tot a
val sel_tot : #a:Type -> h:heap -> r:ref a{h `contains_a_well_typed` r} -> Tot a
let sel_tot #a h r = match h.memory r.addr with | Some (| _ , x |) -> x
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 49, "start_col": 0, "start_line": 47 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr let compare_addrs #a #b r1 r2 = r1.addr = r2.addr let contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) = Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a (* exists (x:a). h.memory r.addr == Some (| a, x |) *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.DM4F.Heap.heap -> r: FStar.DM4F.Heap.ref a {FStar.DM4F.Heap.contains_a_well_typed h r} -> a
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.ref", "FStar.DM4F.Heap.contains_a_well_typed", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__memory", "FStar.DM4F.Heap.__proj__Mkref__item__addr" ]
[]
false
false
false
false
false
let sel_tot #a h r =
match h.memory r.addr with | Some (| _ , x |) -> x
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.upd_tot
val upd_tot : #a:Type -> h0:heap -> r:ref a{h0 `contains_a_well_typed` r} -> x:a -> Tot heap
val upd_tot : #a:Type -> h0:heap -> r:ref a{h0 `contains_a_well_typed` r} -> x:a -> Tot heap
let upd_tot #a h0 r x = { h0 with memory = F.on_dom nat (fun r' -> if r.addr = r' then Some (| a, x |) else h0.memory r') }
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 60, "end_line": 60, "start_col": 0, "start_line": 57 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr let compare_addrs #a #b r1 r2 = r1.addr = r2.addr let contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) = Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a (* exists (x:a). h.memory r.addr == Some (| a, x |) *) (* Select. *) let sel_tot #a h r = match h.memory r.addr with | Some (| _ , x |) -> x let sel #a h r = if FStar.StrongExcludedMiddle.strong_excluded_middle (h `contains_a_well_typed` r) then sel_tot #a h r else r.init
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
h0: FStar.DM4F.Heap.heap -> r: FStar.DM4F.Heap.ref a {FStar.DM4F.Heap.contains_a_well_typed h0 r} -> x: a -> FStar.DM4F.Heap.heap
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.ref", "FStar.DM4F.Heap.contains_a_well_typed", "FStar.DM4F.Heap.Mkheap_rec", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__next_addr", "FStar.FunctionalExtensionality.on_dom", "Prims.nat", "FStar.Pervasives.Native.option", "Prims.dtuple2", "Prims.op_Equality", "FStar.DM4F.Heap.__proj__Mkref__item__addr", "FStar.Pervasives.Native.Some", "Prims.Mkdtuple2", "Prims.bool", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__memory" ]
[]
false
false
false
false
false
let upd_tot #a h0 r x =
{ h0 with memory = F.on_dom nat (fun r' -> if r.addr = r' then Some (| a, x |) else h0.memory r') }
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.compare_addrs
val compare_addrs: #a:Type -> #b:Type -> r1:ref a -> r2:ref b -> Tot (b:bool{b = (addr_of r1 = addr_of r2)})
val compare_addrs: #a:Type -> #b:Type -> r1:ref a -> r2:ref b -> Tot (b:bool{b = (addr_of r1 = addr_of r2)})
let compare_addrs #a #b r1 r2 = r1.addr = r2.addr
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 40, "start_col": 0, "start_line": 40 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
r1: FStar.DM4F.Heap.ref a -> r2: FStar.DM4F.Heap.ref b -> b: Prims.bool{b = (FStar.DM4F.Heap.addr_of r1 = FStar.DM4F.Heap.addr_of r2)}
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.ref", "Prims.op_Equality", "Prims.nat", "FStar.DM4F.Heap.__proj__Mkref__item__addr", "Prims.bool", "Prims.b2t", "FStar.DM4F.Heap.addr_of" ]
[]
false
false
false
false
false
let compare_addrs #a #b r1 r2 =
r1.addr = r2.addr
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.sel
val sel: #a:Type -> h:heap -> r:ref a -> GTot a
val sel: #a:Type -> h:heap -> r:ref a -> GTot a
let sel #a h r = if FStar.StrongExcludedMiddle.strong_excluded_middle (h `contains_a_well_typed` r) then sel_tot #a h r else r.init
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 54, "start_col": 0, "start_line": 51 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr let compare_addrs #a #b r1 r2 = r1.addr = r2.addr let contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) = Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a (* exists (x:a). h.memory r.addr == Some (| a, x |) *) (* Select. *) let sel_tot #a h r = match h.memory r.addr with | Some (| _ , x |) -> x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.DM4F.Heap.heap -> r: FStar.DM4F.Heap.ref a -> Prims.GTot a
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.ref", "FStar.StrongExcludedMiddle.strong_excluded_middle", "FStar.DM4F.Heap.contains_a_well_typed", "FStar.DM4F.Heap.sel_tot", "Prims.bool", "FStar.DM4F.Heap.__proj__Mkref__item__init" ]
[]
false
false
false
false
false
let sel #a h r =
if FStar.StrongExcludedMiddle.strong_excluded_middle (h `contains_a_well_typed` r) then sel_tot #a h r else r.init
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.upd
val upd: #a:Type -> h0:heap -> r:ref a -> x:a -> GTot heap
val upd: #a:Type -> h0:heap -> r:ref a -> x:a -> GTot heap
let upd #a h0 r x = if FStar.StrongExcludedMiddle.strong_excluded_middle (h0 `contains_a_well_typed` r) then upd_tot h0 r x else if r.addr >= h0.next_addr then (* alloc at r.addr *) { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r':nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } else (* type modifying update at r.addr *) { h0 with memory = F.on_dom nat (fun r' -> if r' = r.addr then Some (| a, x |) else h0.memory r') }
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 65, "end_line": 75, "start_col": 0, "start_line": 62 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr let compare_addrs #a #b r1 r2 = r1.addr = r2.addr let contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) = Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a (* exists (x:a). h.memory r.addr == Some (| a, x |) *) (* Select. *) let sel_tot #a h r = match h.memory r.addr with | Some (| _ , x |) -> x let sel #a h r = if FStar.StrongExcludedMiddle.strong_excluded_middle (h `contains_a_well_typed` r) then sel_tot #a h r else r.init (* Update. *) let upd_tot #a h0 r x = { h0 with memory = F.on_dom nat (fun r' -> if r.addr = r' then Some (| a, x |) else h0.memory r') }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
h0: FStar.DM4F.Heap.heap -> r: FStar.DM4F.Heap.ref a -> x: a -> Prims.GTot FStar.DM4F.Heap.heap
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.ref", "FStar.StrongExcludedMiddle.strong_excluded_middle", "FStar.DM4F.Heap.contains_a_well_typed", "FStar.DM4F.Heap.upd_tot", "Prims.bool", "Prims.op_GreaterThanOrEqual", "FStar.DM4F.Heap.__proj__Mkref__item__addr", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__next_addr", "FStar.DM4F.Heap.Mkheap_rec", "Prims.op_Addition", "FStar.FunctionalExtensionality.on_dom", "Prims.nat", "FStar.Pervasives.Native.option", "Prims.dtuple2", "Prims.op_Equality", "FStar.Pervasives.Native.Some", "Prims.Mkdtuple2", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__memory" ]
[]
false
false
false
false
false
let upd #a h0 r x =
if FStar.StrongExcludedMiddle.strong_excluded_middle (h0 `contains_a_well_typed` r) then upd_tot h0 r x else if r.addr >= h0.next_addr then { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r': nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } else { h0 with memory = F.on_dom nat (fun r' -> if r' = r.addr then Some (| a, x |) else h0.memory r') }
false
EverCrypt.AEAD.fst
EverCrypt.AEAD.decrypt_aes_gcm
val decrypt_aes_gcm (i: vale_impl) : decrypt_st (alg_of_vale_impl i)
val decrypt_aes_gcm (i: vale_impl) : decrypt_st (alg_of_vale_impl i)
let decrypt_aes_gcm (i: vale_impl): decrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let a = alg_of_vale_impl i in let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let r = aes_gcm_decrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) cipher (uint32_to_uint64 cipher_len) ad (uint32_to_uint64 ad_len) tmp_iv dst tag keys_b hkeys_b scratch_b in let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let cipher_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 cipher) in let tag_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 tag) in let plain_nat, success = Vale.AES.GCM_s.gcm_decrypt_LE (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat in Seq.equal (B.as_seq h1 dst) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 plain_nat) /\ (UInt64.v r = 0) == success); assert ( let kv = G.reveal kv in let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in Seq.equal (Seq.slice cipher_tag (S.length cipher_tag - tag_length a) (S.length cipher_tag)) (B.as_seq h0 tag) /\ Seq.equal (Seq.slice cipher_tag 0 (S.length cipher_tag - tag_length a)) (B.as_seq h0 cipher)); pop_frame(); if r = 0uL then Success else AuthenticationFailure
{ "file_name": "providers/evercrypt/fst/EverCrypt.AEAD.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 553, "start_col": 0, "start_line": 443 }
module EverCrypt.AEAD module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open FStar.Int.Cast open Spec.Agile.AEAD open Spec.Cipher.Expansion open EverCrypt.CTR.Keys friend Spec.Agile.AEAD friend Spec.Cipher.Expansion friend EverCrypt.CTR.Keys #set-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0" /// Defining abstract predicates, invariants, footprint, etc. /// --------------------------------------------------------- let _: squash (inversion impl) = allow_inversion impl /// We now distinguish between an expanded key (as mandated by NIST spec) and a /// **concrete** expanded key, which may contain implementation-specific details /// and extra precomputations. In the rest of this module, we rely on concrete /// expanded keys, which are parameterized over an implementation, instead of /// regular expanded keys, which are parameterized over an algorithm. Helpers /// allow us to move from one notion to the other. let supported_alg_of_impl (i: impl): supported_alg = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM | Hacl_CHACHA20 -> CHACHA20_POLY1305 inline_for_extraction noextract let alg_of_vale_impl (i: vale_impl) = match i with | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM noeq type state_s a = | Ek: impl:impl -> kv:G.erased (kv a) -> ek:B.buffer UInt8.t -> // concrete expanded key state_s a let invert_state_s (a: alg): Lemma (requires True) (ensures (inversion (state_s a))) [ SMTPat (state_s a) ] = allow_inversion (state_s a) let freeable_s #a (Ek _ _ ek) = B.freeable ek let footprint_s #a (Ek _ _ ek) = B.loc_addr_of_buffer ek let invariant_s #a h (Ek i kv ek) = is_supported_alg a /\ a = supported_alg_of_impl i /\ B.live h ek /\ B.length ek >= concrete_xkey_length i /\ B.as_seq h (B.gsub ek 0ul (UInt32.uint_to_t (concrete_xkey_length i))) `S.equal` concrete_expand i (G.reveal kv) /\ config_pre a /\ ( match i with | Vale_AES128 | Vale_AES256 -> // Expanded key length + precomputed stuff + scratch space (AES-GCM specific) B.length ek = vale_xkey_length (cipher_alg_of_supported_alg a) + 176 | Hacl_CHACHA20 -> B.length ek = concrete_xkey_length i) let invariant_loc_in_footprint #a s m = () let frame_invariant #a l s h0 h1 = () /// Actual stateful API /// ------------------- let alg_of_state a s = let open LowStar.BufferOps in let Ek impl _ _ = !*s in match impl with | Hacl_CHACHA20 -> CHACHA20_POLY1305 | Vale_AES128 -> AES128_GCM | Vale_AES256 -> AES256_GCM let as_kv #a (Ek _ kv _) = G.reveal kv #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" let create_in_chacha20_poly1305: create_in_st CHACHA20_POLY1305 = fun r dst k -> let h0 = ST.get () in let ek = B.malloc r 0uy 32ul in let p = B.malloc r (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; B.upd dst 0ul p; let h2 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h0 h2; Success #pop-options inline_for_extraction noextract let create_in_aes_gcm (i: vale_impl): create_in_st (alg_of_vale_impl i) = fun r dst k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in if EverCrypt.TargetConfig.hacl_can_compile_vale then ( let has_aesni = EverCrypt.AutoConfig2.has_aesni () in let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then ( let ek = B.malloc r 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.malloc r (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in let open LowStar.BufferOps in dst *= p; let h3 = ST.get() in B.modifies_only_not_unused_in B.(loc_buffer dst) h2 h3; Success ) else UnsupportedAlgorithm ) else UnsupportedAlgorithm let create_in_aes128_gcm: create_in_st AES128_GCM = create_in_aes_gcm Vale_AES128 let create_in_aes256_gcm: create_in_st AES256_GCM = create_in_aes_gcm Vale_AES256 let create_in #a r dst k = match a with | AES128_GCM -> create_in_aes128_gcm r dst k | AES256_GCM -> create_in_aes256_gcm r dst k | CHACHA20_POLY1305 -> create_in_chacha20_poly1305 r dst k | _ -> UnsupportedAlgorithm #push-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.QI.EAGER_THRESHOLD=5" inline_for_extraction noextract let alloca_chacha20_poly1305: alloca_st CHACHA20_POLY1305 = fun k -> let h0 = ST.get () in let ek = B.alloca 0uy 32ul in let p = B.alloca (Ek Hacl_CHACHA20 (G.hide (B.as_seq h0 k)) ek) 1ul in B.blit k 0ul ek 0ul 32ul; let h3 = ST.get() in B.modifies_only_not_unused_in B.loc_none h0 h3; p #pop-options inline_for_extraction noextract let alloca_aes_gcm (i: vale_impl): alloca_st (alg_of_vale_impl i) = fun k -> let a = alg_of_vale_impl i in let h0 = ST.get () in let kv: G.erased (kv a) = G.hide (B.as_seq h0 k) in let ek = B.alloca 0uy (concrete_xkey_len i + 176ul) in vale_expand i k ek; let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h0 h2; let p = B.alloca (Ek i (G.hide (B.as_seq h0 k)) ek) 1ul in p inline_for_extraction noextract let alloca_aes128_gcm: alloca_st AES128_GCM = alloca_aes_gcm Vale_AES128 inline_for_extraction noextract let alloca_aes256_gcm: alloca_st AES256_GCM = alloca_aes_gcm Vale_AES256 let alloca #a k = match a with | AES128_GCM -> alloca_aes128_gcm k | AES256_GCM -> alloca_aes256_gcm k | CHACHA20_POLY1305 -> alloca_chacha20_poly1305 k inline_for_extraction noextract let aes_gcm_encrypt (i: vale_impl): Vale.Wrapper.X64.GCMencryptOpt.encrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMencryptOpt256.gcm256_encrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'" inline_for_extraction noextract let encrypt_aes_gcm (i: vale_impl): encrypt_st (alg_of_vale_impl i) = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if B.is_null s then InvalidKey else let a = alg_of_vale_impl i in // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len = 0ul then InvalidIVLength else let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert ( let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame(); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get() in // The iv can be arbitrary length, hence we need to allocate a new one to perform the hashing let tmp_iv = B.alloca 0uy 16ul in // There is no SMTPat on le_bytes_to_seq_quad32_to_bytes and the converse, // so we need an explicit lemma let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc (==) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); (==) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); // We perform the hashing of the iv. The extra buffer and the hashed iv are the same Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w ) iv iv_len tmp_iv tmp_iv hkeys_b; let h0 = get() in aes_gcm_encrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) plain (uint32_to_uint64 plain_len) ad (uint32_to_uint64 ad_len) tmp_iv cipher tag keys_b hkeys_b scratch_b; let h1 = get() in // This assert is needed for z3 to pick up sequence equality for ciphertext // and tag. It could be avoided if the spec returned both instead of appending them assert ( let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in // `ad` is called `auth` in Vale world; "additional data", "authenticated // data", potato, potato let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let plain_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 plain) in let cipher_nat, tag_nat = Vale.AES.GCM_s.gcm_encrypt_LE (vale_alg_of_alg a) kv_nat iv_nat plain_nat ad_nat in Seq.equal (B.as_seq h1 cipher) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 cipher_nat) /\ Seq.equal (B.as_seq h1 tag) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 tag_nat)); pop_frame(); Success let encrypt_aes128_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES128_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES128 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt_aes256_gcm (_: squash (EverCrypt.TargetConfig.hacl_can_compile_vale)): encrypt_st AES256_GCM = fun s iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_aes_gcm Vale_AES256 s iv iv_len ad ad_len plain plain_len cipher tag else let () = false_elim () in LowStar.Failure.failwith "statically unreachable" let encrypt #a s iv iv_len ad ad_len plain plain_len cipher tag = if B.is_null s then InvalidKey else let open LowStar.BufferOps in let Ek i kv ek = !*s in match i with | Vale_AES128 -> encrypt_aes128_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Vale_AES256 -> encrypt_aes256_gcm () s iv iv_len ad ad_len plain plain_len cipher tag | Hacl_CHACHA20 -> // This condition is never satisfied in F* because of the iv_length precondition on iv. // We keep it here to be defensive when extracting to C if iv_len <> 12ul then InvalidIVLength else begin // Length restrictions assert_norm (pow2 31 + pow2 32 / 64 <= pow2 32 - 1); EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; Success end inline_for_extraction noextract let encrypt_expand_aes_gcm (i: vale_impl): encrypt_expand_st false (alg_of_vale_impl i) = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s (alg_of_vale_impl i)) = alloca k in let r = encrypt_aes_gcm i s iv iv_len ad ad_len plain plain_len cipher tag in assert(r == Success); pop_frame (); Success let encrypt_expand_aes128_gcm_no_check : encrypt_expand_st false AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes256_gcm_no_check : encrypt_expand_st false AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else LowStar.Failure.failwith "EverCrypt was compiled on a system which doesn't support Vale" let encrypt_expand_aes128_gcm : encrypt_expand_st true AES128_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES128 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_aes256_gcm : encrypt_expand_st true AES256_GCM = fun k iv iv_len ad ad_len plain plain_len cipher tag -> if EverCrypt.TargetConfig.hacl_can_compile_vale then let has_pclmulqdq = EverCrypt.AutoConfig2.has_pclmulqdq () in let has_avx = EverCrypt.AutoConfig2.has_avx() in let has_sse = EverCrypt.AutoConfig2.has_sse() in let has_movbe = EverCrypt.AutoConfig2.has_movbe() in let has_aesni = EverCrypt.AutoConfig2.has_aesni () in if (has_aesni && has_pclmulqdq && has_avx && has_sse && has_movbe) then encrypt_expand_aes_gcm Vale_AES256 k iv iv_len ad ad_len plain plain_len cipher tag else UnsupportedAlgorithm else UnsupportedAlgorithm let encrypt_expand_chacha20_poly1305 : encrypt_expand_st false CHACHA20_POLY1305 = fun k iv iv_len ad ad_len plain plain_len cipher tag -> push_frame (); (* Allocate the state *) let s : B.pointer_or_null (state_s CHACHA20_POLY1305) = alloca k in let open LowStar.BufferOps in let Ek i kv ek = !*s in EverCrypt.Chacha20Poly1305.aead_encrypt ek iv ad_len ad plain_len plain cipher tag; pop_frame (); Success let encrypt_expand #a k iv iv_len ad ad_len plain plain_len cipher tag = match a with | AES128_GCM -> encrypt_expand_aes128_gcm k iv iv_len ad ad_len plain plain_len cipher tag | AES256_GCM -> encrypt_expand_aes256_gcm k iv iv_len ad ad_len plain plain_len cipher tag | CHACHA20_POLY1305 -> encrypt_expand_chacha20_poly1305 k iv iv_len ad ad_len plain plain_len cipher tag inline_for_extraction noextract let aes_gcm_decrypt (i: vale_impl): Vale.Wrapper.X64.GCMdecryptOpt.decrypt_opt_stdcall_st (vale_alg_of_vale_impl i) = match i with | Vale_AES128 -> Vale.Wrapper.X64.GCMdecryptOpt.gcm128_decrypt_opt_stdcall | Vale_AES256 -> Vale.Wrapper.X64.GCMdecryptOpt256.gcm256_decrypt_opt_stdcall #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties.slice_slice'"
{ "checked_file": "/", "dependencies": [ "Vale.Wrapper.X64.GCMencryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMencryptOpt.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt256.fsti.checked", "Vale.Wrapper.X64.GCMdecryptOpt.fsti.checked", "Vale.Wrapper.X64.GCM_IV.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Cipher.Expansion.fst.checked", "Spec.Agile.AEAD.fst.checked", "Spec.Agile.AEAD.fst.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.CTR.Keys.fst.checked", "EverCrypt.Chacha20Poly1305.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": true, "source_file": "EverCrypt.AEAD.fst" }
[ { "abbrev": false, "full_module": "EverCrypt.CTR.Keys", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher.Expansion", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "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": 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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: EverCrypt.CTR.Keys.vale_impl -> EverCrypt.AEAD.decrypt_st (EverCrypt.AEAD.alg_of_vale_impl i)
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.CTR.Keys.vale_impl", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.state_s", "EverCrypt.AEAD.alg_of_vale_impl", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "LowStar.Monotonic.Buffer.length", "EverCrypt.CTR.Keys.uint8", "LowStar.Buffer.trivial_preorder", "FStar.Integers.op_Greater", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.cipher_p", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.tag_length", "Prims.nat", "EverCrypt.Error.InvalidKey", "EverCrypt.Error.error_code", "Prims.bool", "FStar.UInt32.__uint_to_t", "EverCrypt.Error.InvalidIVLength", "Spec.Cipher.Expansion.impl", "FStar.Ghost.erased", "Spec.Agile.AEAD.kv", "FStar.UInt8.t", "FStar.UInt64.t", "FStar.UInt64.__uint_to_t", "EverCrypt.Error.Success", "EverCrypt.Error.AuthenticationFailure", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "FStar.Integers.op_Subtraction", "FStar.Seq.Base.length", "LowStar.Monotonic.Buffer.as_seq", "FStar.Seq.Base.seq", "FStar.Seq.Base.append", "FStar.Ghost.reveal", "Vale.Def.Types_s.nat8", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8", "Prims.eq2", "FStar.UInt64.v", "FStar.Pervasives.Native.tuple2", "Vale.Def.Words_s.nat8", "Vale.AES.GCM_s.gcm_decrypt_LE", "Spec.Agile.AEAD.vale_alg_of_alg", "Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverCrypt.AEAD.aes_gcm_decrypt", "FStar.Ghost.hide", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.nat32", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Int.Cast.uint32_to_uint64", "Vale.Wrapper.X64.GCM_IV.compute_iv", "Prims.l_True", "Prims.squash", "Vale.AES.OptPublic.hkeys_reqs_pub", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.Def.Words_s.Mkfour", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Calc.calc_finish", "Vale.Def.Types_s.quad32", "Prims.Cons", "FStar.Preorder.relation", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "FStar.Seq.Properties.lseq", "Vale.AES.OptPublic.get_hkeys_reqs", "LowStar.Monotonic.Buffer.mbuffer", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca", "FStar.UInt8.__uint_to_t", "LowStar.Buffer.sub", "EverCrypt.CTR.Keys.key_offset", "EverCrypt.CTR.Keys.concrete_xkey_len", "FStar.HyperStack.ST.push_frame", "Vale.AES.AES_s.is_aes_key_LE", "LowStar.BufferOps.op_Bang_Star", "Spec.Agile.AEAD.alg", "LowStar.Monotonic.Buffer.is_null", "EverCrypt.AEAD.decrypt_st" ]
[]
false
false
false
false
false
let decrypt_aes_gcm (i: vale_impl) : decrypt_st (alg_of_vale_impl i) =
fun s iv iv_len ad ad_len cipher cipher_len tag dst -> if B.is_null s then InvalidKey else if iv_len = 0ul then InvalidIVLength else let a = alg_of_vale_impl i in let open LowStar.BufferOps in let Ek _ kv ek = !*s in assert (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.AES_s.is_aes_key_LE (vale_alg_of_alg a) k_w); push_frame (); let scratch_b = B.sub ek (concrete_xkey_len i) 176ul in let ek = B.sub ek 0ul (concrete_xkey_len i) in let keys_b = B.sub ek 0ul (key_offset i) in let hkeys_b = B.sub ek (key_offset i) 128ul in let h0 = get () in let tmp_iv = B.alloca 0uy 16ul in let lemma_hkeys_reqs () : Lemma (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in Vale.AES.OptPublic.hkeys_reqs_pub (Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0)))) = let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE (vale_alg_of_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad ) in assert (Seq.equal (B.as_seq h0 hkeys_b) hkeys); calc ( == ) { Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 hkeys); ( == ) { Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes hkeys_quad } hkeys_quad; } in lemma_hkeys_reqs (); Vale.Wrapper.X64.GCM_IV.compute_iv (vale_alg_of_alg a) (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) iv iv_len tmp_iv tmp_iv hkeys_b; let r = aes_gcm_decrypt i (let k = G.reveal kv in let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in G.hide k_w) (Ghost.hide (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv))) cipher (uint32_to_uint64 cipher_len) ad (uint32_to_uint64 ad_len) tmp_iv dst tag keys_b hkeys_b scratch_b in let h1 = get () in assert (let kv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (G.reveal kv) in let iv_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 iv) in let ad_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 ad) in let cipher_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 cipher) in let tag_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (B.as_seq h0 tag) in let plain_nat, success = Vale.AES.GCM_s.gcm_decrypt_LE (vale_alg_of_alg a) kv_nat iv_nat cipher_nat ad_nat tag_nat in Seq.equal (B.as_seq h1 dst) (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 plain_nat) /\ (UInt64.v r = 0) == success); assert (let kv = G.reveal kv in let cipher_tag = (B.as_seq h0 cipher) `S.append` (B.as_seq h0 tag) in Seq.equal (Seq.slice cipher_tag (S.length cipher_tag - tag_length a) (S.length cipher_tag) ) (B.as_seq h0 tag) /\ Seq.equal (Seq.slice cipher_tag 0 (S.length cipher_tag - tag_length a)) (B.as_seq h0 cipher)); pop_frame (); if r = 0uL then Success else AuthenticationFailure
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.alloc
val alloc: #a:Type -> h0:heap -> x:a -> Tot (t:(ref a * heap){snd t == upd h0 (fst t) x})
val alloc: #a:Type -> h0:heap -> x:a -> Tot (t:(ref a * heap){snd t == upd h0 (fst t) x})
let alloc #a h0 x = let r = { addr = h0.next_addr; init = x } in let h1 = { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r':nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } in assert (let h2 = upd h0 r x in FStar.FunctionalExtensionality.feq h1.memory h2.memory); r, h1
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 88, "start_col": 0, "start_line": 79 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr let compare_addrs #a #b r1 r2 = r1.addr = r2.addr let contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) = Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a (* exists (x:a). h.memory r.addr == Some (| a, x |) *) (* Select. *) let sel_tot #a h r = match h.memory r.addr with | Some (| _ , x |) -> x let sel #a h r = if FStar.StrongExcludedMiddle.strong_excluded_middle (h `contains_a_well_typed` r) then sel_tot #a h r else r.init (* Update. *) let upd_tot #a h0 r x = { h0 with memory = F.on_dom nat (fun r' -> if r.addr = r' then Some (| a, x |) else h0.memory r') } let upd #a h0 r x = if FStar.StrongExcludedMiddle.strong_excluded_middle (h0 `contains_a_well_typed` r) then upd_tot h0 r x else if r.addr >= h0.next_addr then (* alloc at r.addr *) { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r':nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } else (* type modifying update at r.addr *) { h0 with memory = F.on_dom nat (fun r' -> if r' = r.addr then Some (| a, x |) else h0.memory r') } (* Generating a fresh reference for the given heap. *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
h0: FStar.DM4F.Heap.heap -> x: a -> t: (FStar.DM4F.Heap.ref a * FStar.DM4F.Heap.heap) {FStar.Pervasives.Native.snd t == FStar.DM4F.Heap.upd h0 (FStar.Pervasives.Native.fst t) x}
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.heap", "FStar.Pervasives.Native.Mktuple2", "FStar.DM4F.Heap.ref", "Prims.unit", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.nat", "FStar.Pervasives.Native.option", "Prims.dtuple2", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__memory", "FStar.DM4F.Heap.upd", "FStar.DM4F.Heap.heap_rec", "FStar.DM4F.Heap.Mkheap_rec", "Prims.op_Addition", "FStar.DM4F.Heap.__proj__Mkref__item__addr", "FStar.FunctionalExtensionality.on_dom", "Prims.op_Equality", "FStar.Pervasives.Native.Some", "Prims.Mkdtuple2", "Prims.bool", "FStar.DM4F.Heap.Mkref", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__next_addr", "FStar.Pervasives.Native.tuple2", "Prims.eq2", "FStar.Pervasives.Native.snd", "FStar.Pervasives.Native.fst" ]
[]
false
false
false
false
false
let alloc #a h0 x =
let r = { addr = h0.next_addr; init = x } in let h1 = { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r': nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } in assert (let h2 = upd h0 r x in FStar.FunctionalExtensionality.feq h1.memory h2.memory); r, h1
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.upd_sel
val upd_sel : #a:Type -> h:heap -> r:ref a -> Lemma (requires (h `contains_a_well_typed` r)) (ensures (upd h r (sel h r) == h)) [SMTPat (upd h r (sel h r))]
val upd_sel : #a:Type -> h:heap -> r:ref a -> Lemma (requires (h `contains_a_well_typed` r)) (ensures (upd h r (sel h r) == h)) [SMTPat (upd h r (sel h r))]
let upd_sel #a h r = assert (FStar.FunctionalExtensionality.feq (upd h r (sel h r)).memory h.memory)
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 81, "end_line": 109, "start_col": 0, "start_line": 108 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr let compare_addrs #a #b r1 r2 = r1.addr = r2.addr let contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) = Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a (* exists (x:a). h.memory r.addr == Some (| a, x |) *) (* Select. *) let sel_tot #a h r = match h.memory r.addr with | Some (| _ , x |) -> x let sel #a h r = if FStar.StrongExcludedMiddle.strong_excluded_middle (h `contains_a_well_typed` r) then sel_tot #a h r else r.init (* Update. *) let upd_tot #a h0 r x = { h0 with memory = F.on_dom nat (fun r' -> if r.addr = r' then Some (| a, x |) else h0.memory r') } let upd #a h0 r x = if FStar.StrongExcludedMiddle.strong_excluded_middle (h0 `contains_a_well_typed` r) then upd_tot h0 r x else if r.addr >= h0.next_addr then (* alloc at r.addr *) { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r':nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } else (* type modifying update at r.addr *) { h0 with memory = F.on_dom nat (fun r' -> if r' = r.addr then Some (| a, x |) else h0.memory r') } (* Generating a fresh reference for the given heap. *) let alloc #a h0 x = let r = { addr = h0.next_addr; init = x } in let h1 = { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r':nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } in assert (let h2 = upd h0 r x in FStar.FunctionalExtensionality.feq h1.memory h2.memory); r, h1 let contains (#a:Type) (h:heap) (r:ref a): Tot Type0 = Some? (h.memory r.addr) let contains_a_well_typed_implies_contains #a h r = () let contains_addr_of #a #b h r1 r2 = () let alloc_lemma #a h0 x = () let sel_same_addr_of (#a:Type) (x:ref a) (y:ref a) (h:heap) :Lemma (requires (addr_of x = addr_of y /\ h `contains_a_well_typed` x /\ h `contains_a_well_typed` y)) (ensures (sel h x == sel h y)) [SMTPat (sel h x); SMTPat (sel h y)] = () let sel_upd1 #a h r v r' = () let sel_upd2 #a #b h k1 k2 v = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.DM4F.Heap.heap -> r: FStar.DM4F.Heap.ref a -> FStar.Pervasives.Lemma (requires FStar.DM4F.Heap.contains_a_well_typed h r) (ensures FStar.DM4F.Heap.upd h r (FStar.DM4F.Heap.sel h r) == h) [SMTPat (FStar.DM4F.Heap.upd h r (FStar.DM4F.Heap.sel h r))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.ref", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.nat", "FStar.Pervasives.Native.option", "Prims.dtuple2", "FStar.DM4F.Heap.__proj__Mkheap_rec__item__memory", "FStar.DM4F.Heap.upd", "FStar.DM4F.Heap.sel", "Prims.unit" ]
[]
false
false
true
false
false
let upd_sel #a h r =
assert (FStar.FunctionalExtensionality.feq (upd h r (sel h r)).memory h.memory)
false
FStar.DM4F.Heap.fst
FStar.DM4F.Heap.emp
val emp : heap
val emp : heap
let emp = { next_addr = 0; memory = F.on_dom nat (fun (r:nat) -> None) }
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 1, "end_line": 114, "start_col": 0, "start_line": 111 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Heap open FStar.Classical open FStar.Set module F = FStar.FunctionalExtensionality noeq type heap_rec = { next_addr: nat; memory : F.restricted_t nat (fun _ -> option (a:Type0 & a)) } type heap = h:heap_rec{(forall (n:nat). n >= h.next_addr ==> None? (h.memory n))} private let consistent (h0:heap) (h1:heap) = forall n x y. h0.memory n == Some x /\ h1.memory n == Some y ==> dfst x == dfst y noeq type ref (a:Type0) = { addr: nat; init: a } let addr_of #a r = r.addr let compare_addrs #a #b r1 r2 = r1.addr = r2.addr let contains_a_well_typed (#a:Type0) (h:heap) (r:ref a) = Some? (h.memory r.addr) /\ dfst (Some?.v (h.memory r.addr)) == a (* exists (x:a). h.memory r.addr == Some (| a, x |) *) (* Select. *) let sel_tot #a h r = match h.memory r.addr with | Some (| _ , x |) -> x let sel #a h r = if FStar.StrongExcludedMiddle.strong_excluded_middle (h `contains_a_well_typed` r) then sel_tot #a h r else r.init (* Update. *) let upd_tot #a h0 r x = { h0 with memory = F.on_dom nat (fun r' -> if r.addr = r' then Some (| a, x |) else h0.memory r') } let upd #a h0 r x = if FStar.StrongExcludedMiddle.strong_excluded_middle (h0 `contains_a_well_typed` r) then upd_tot h0 r x else if r.addr >= h0.next_addr then (* alloc at r.addr *) { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r':nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } else (* type modifying update at r.addr *) { h0 with memory = F.on_dom nat (fun r' -> if r' = r.addr then Some (| a, x |) else h0.memory r') } (* Generating a fresh reference for the given heap. *) let alloc #a h0 x = let r = { addr = h0.next_addr; init = x } in let h1 = { next_addr = r.addr + 1; memory = F.on_dom nat (fun (r':nat) -> if r' = r.addr then Some (| a, x |) else h0.memory r') } in assert (let h2 = upd h0 r x in FStar.FunctionalExtensionality.feq h1.memory h2.memory); r, h1 let contains (#a:Type) (h:heap) (r:ref a): Tot Type0 = Some? (h.memory r.addr) let contains_a_well_typed_implies_contains #a h r = () let contains_addr_of #a #b h r1 r2 = () let alloc_lemma #a h0 x = () let sel_same_addr_of (#a:Type) (x:ref a) (y:ref a) (h:heap) :Lemma (requires (addr_of x = addr_of y /\ h `contains_a_well_typed` x /\ h `contains_a_well_typed` y)) (ensures (sel h x == sel h y)) [SMTPat (sel h x); SMTPat (sel h y)] = () let sel_upd1 #a h r v r' = () let sel_upd2 #a #b h k1 k2 v = () let upd_sel #a h r = assert (FStar.FunctionalExtensionality.feq (upd h r (sel h r)).memory h.memory)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.fst" }
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.DM4F.Heap.heap
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.Mkheap_rec", "FStar.FunctionalExtensionality.on_dom", "Prims.nat", "FStar.Pervasives.Native.option", "Prims.dtuple2", "FStar.Pervasives.Native.None" ]
[]
false
false
false
true
false
let emp =
{ next_addr = 0; memory = F.on_dom nat (fun (r: nat) -> None) }
false
Steel.PCMReference.fst
Steel.PCMReference.split
val split (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v:erased a) (v0:erased a) (v1:erased a) : SteelGhost unit inames (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == hide (op p v0 v1)) (ensures fun _ _ _ -> True)
val split (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v:erased a) (v0:erased a) (v1:erased a) : SteelGhost unit inames (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == hide (op p v0 v1)) (ensures fun _ _ _ -> True)
let split #_ #a #p r v v0 v1 = let _:squash (composable p v0 v1) = () in rewrite_slprop (pts_to r v) (pts_to r (op p v0 v1)) (fun _ -> ()); split' r v0 v1; rewrite_slprop (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (pts_to r v0 `star` pts_to r v1) (fun _ -> ())
{ "file_name": "lib/steel/Steel.PCMReference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 60, "start_col": 0, "start_line": 54 }
(* Copyright 2020 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 Steel.PCMReference module Mem = Steel.Memory let read r v0 = let v = as_action (sel_action FStar.Set.empty r v0) in v let write r v0 v1 = as_action (upd_action FStar.Set.empty r v0 v1) val alloc' (#a:Type) (#pcm:pcm a) (x:a) : Steel (ref a pcm) (to_vprop Mem.emp) (fun r -> pts_to r x) (requires fun _ -> compatible pcm x x /\ pcm.refine x) (ensures fun _ _ _ -> True) let alloc' x = as_action (alloc_action FStar.Set.empty x) let alloc #_ #pcm x = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); compatible_refl pcm x; alloc' x let free r x = as_action (free_action FStar.Set.empty r x) val split' (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v0:erased a) (v1:erased a{composable p v0 v1}) : SteelGhostT unit inames (pts_to r (op p v0 v1)) (fun _ -> to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) let split' #inames #a #p r v0 v1 = as_atomic_action_ghost (split_action inames r v0 v1)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked" ], "interface_file": true, "source_file": "Steel.PCMReference.fst" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
r: Steel.Memory.ref a p -> v: FStar.Ghost.erased a -> v0: FStar.Ghost.erased a -> v1: FStar.Ghost.erased a -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.Effect.Atomic.rewrite_slprop", "Steel.Effect.Common.to_vprop", "Steel.Memory.star", "Steel.Memory.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.star", "Steel.PCMReference.pts_to", "Steel.Memory.mem", "Prims.unit", "Steel.PCMReference.split'", "FStar.PCM.op", "Prims.squash", "FStar.PCM.composable" ]
[]
false
true
false
false
false
let split #_ #a #p r v v0 v1 =
let _:squash (composable p v0 v1) = () in rewrite_slprop (pts_to r v) (pts_to r (op p v0 v1)) (fun _ -> ()); split' r v0 v1; rewrite_slprop (to_vprop Mem.((pts_to r v0) `star` (pts_to r v1))) ((pts_to r v0) `star` (pts_to r v1)) (fun _ -> ())
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.is_map_of
val is_map_of : m: Vale.X64.Leakage_Helpers.regmap -> rs: Vale.X64.Leakage_s.reg_taint -> Prims.logical
let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 20, "start_col": 0, "start_line": 19 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
m: Vale.X64.Leakage_Helpers.regmap -> rs: Vale.X64.Leakage_s.reg_taint -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.regmap", "Vale.X64.Leakage_s.reg_taint", "FStar.FunctionalExtensionality.feq", "Vale.X64.Machine_s.reg", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_Helpers.map_to_regs", "Prims.logical" ]
[]
false
false
false
true
true
let is_map_of (m: regmap) (rs: reg_taint) =
FStar.FunctionalExtensionality.feq (map_to_regs m) rs
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.merge_taint
val merge_taint (t1 t2: taint) : taint
val merge_taint (t1 t2: taint) : taint
let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 44, "start_col": 0, "start_line": 42 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
t1: Vale.Arch.HeapTypes_s.taint -> t2: Vale.Arch.HeapTypes_s.taint -> Vale.Arch.HeapTypes_s.taint
Prims.Tot
[ "total" ]
[]
[ "Vale.Arch.HeapTypes_s.taint", "Prims.op_BarBar", "Vale.Arch.HeapTypes_s.uu___is_Secret", "Vale.Arch.HeapTypes_s.Secret", "Prims.bool", "Vale.Arch.HeapTypes_s.Public" ]
[]
false
false
false
true
false
let merge_taint (t1 t2: taint) : taint =
if Secret? t1 || Secret? t2 then Secret else Public
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.reg_le
val reg_le (r1 r2: reg) : bool
val reg_le (r1 r2: reg) : bool
let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 14, "start_col": 0, "start_line": 11 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
r1: Vale.X64.Machine_s.reg -> r2: Vale.X64.Machine_s.reg -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.reg_file_id", "Vale.X64.Machine_s.reg_id", "Prims.op_BarBar", "Prims.op_LessThan", "Prims.op_AmpAmp", "Prims.op_Equality", "Prims.op_LessThanOrEqual", "Prims.bool" ]
[]
false
false
false
true
false
let reg_le (r1 r2: reg) : bool =
let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.regmap
val regmap : Type0
let regmap = map reg taint
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 9, "start_col": 0, "start_line": 9 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Lib.MapTree.map", "Vale.X64.Machine_s.reg", "Vale.Arch.HeapTypes_s.taint" ]
[]
false
false
false
true
true
let regmap =
map reg taint
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.map_to_regs
val map_to_regs (m: regmap) : reg_taint
val map_to_regs (m: regmap) : reg_taint
let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 17, "start_col": 0, "start_line": 16 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
m: Vale.X64.Leakage_Helpers.regmap -> Vale.X64.Leakage_s.reg_taint
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.regmap", "FStar.FunctionalExtensionality.on", "Vale.X64.Machine_s.reg", "Vale.Arch.HeapTypes_s.taint", "Vale.Lib.MapTree.sel", "Vale.X64.Leakage_s.reg_taint" ]
[]
false
false
false
true
false
let map_to_regs (m: regmap) : reg_taint =
FunctionalExtensionality.on reg (sel m)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.ins_consumes_fixed_time
val ins_consumes_fixed_time : ins: Vale.X64.Machine_Semantics_s.ins -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> res: (Prims.bool * Vale.X64.Leakage_Helpers.analysis_taints) -> Prims.logical
let ins_consumes_fixed_time (ins:ins) (ts:analysis_taints) (res:bool & analysis_taints) = let (b, ts') = res in (b2t b ==> isConstantTime (Ins ins) ts.lts)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 155, "start_col": 0, "start_line": 153 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
ins: Vale.X64.Machine_Semantics_s.ins -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> res: (Prims.bool * Vale.X64.Leakage_Helpers.analysis_taints) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Leakage_Helpers.analysis_taints", "FStar.Pervasives.Native.tuple2", "Prims.bool", "Prims.l_imp", "Prims.b2t", "Vale.X64.Leakage_s.isConstantTime", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Leakage_Helpers.__proj__AnalysisTaints__item__lts", "Prims.logical" ]
[]
false
false
false
true
true
let ins_consumes_fixed_time (ins: ins) (ts: analysis_taints) (res: bool & analysis_taints) =
let b, ts' = res in (b2t b ==> isConstantTime (Ins ins) ts.lts)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.publicCfFlagValuesAreAsExpected
val publicCfFlagValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
val publicCfFlagValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
let publicCfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.cfFlagsTaint = Public && tsAnalysis.lts.cfFlagsTaint = Public) || (tsExpected.lts.cfFlagsTaint = Secret)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 122, "end_line": 163, "start_col": 0, "start_line": 162 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts let ins_consumes_fixed_time (ins:ins) (ts:analysis_taints) (res:bool & analysis_taints) = let (b, ts') = res in (b2t b ==> isConstantTime (Ins ins) ts.lts) #set-options "--z3rlimit 20" let publicFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.flagsTaint = Public && tsAnalysis.lts.flagsTaint = Public) || (tsExpected.lts.flagsTaint = Secret)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tsAnalysis: Vale.X64.Leakage_Helpers.analysis_taints -> tsExpected: Vale.X64.Leakage_Helpers.analysis_taints -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.analysis_taints", "Prims.op_BarBar", "Prims.op_AmpAmp", "Prims.op_Equality", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_s.__proj__LeakageTaints__item__cfFlagsTaint", "Vale.X64.Leakage_Helpers.__proj__AnalysisTaints__item__lts", "Vale.Arch.HeapTypes_s.Public", "Vale.Arch.HeapTypes_s.Secret", "Prims.bool" ]
[]
false
false
false
true
false
let publicCfFlagValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool =
(tsExpected.lts.cfFlagsTaint = Public && tsAnalysis.lts.cfFlagsTaint = Public) || (tsExpected.lts.cfFlagsTaint = Secret)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.regs_to_map
val regs_to_map (rs: reg_taint) : (m: regmap{is_map_of m rs})
val regs_to_map (rs: reg_taint) : (m: regmap{is_map_of m rs})
let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 37, "start_col": 0, "start_line": 36 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
rs: Vale.X64.Leakage_s.reg_taint -> m: Vale.X64.Leakage_Helpers.regmap{Vale.X64.Leakage_Helpers.is_map_of m rs}
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_s.reg_taint", "Vale.X64.Leakage_Helpers.regs_to_map_rec", "Vale.X64.Machine_s.n_reg_files", "Vale.X64.Leakage_Helpers.regmap", "Vale.X64.Leakage_Helpers.is_map_of" ]
[]
false
false
false
false
false
let regs_to_map (rs: reg_taint) : (m: regmap{is_map_of m rs}) =
regs_to_map_rec rs n_reg_files 0
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.publicFlagValuesAreAsExpected
val publicFlagValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
val publicFlagValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
let publicFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.flagsTaint = Public && tsAnalysis.lts.flagsTaint = Public) || (tsExpected.lts.flagsTaint = Secret)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 116, "end_line": 160, "start_col": 0, "start_line": 159 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts let ins_consumes_fixed_time (ins:ins) (ts:analysis_taints) (res:bool & analysis_taints) = let (b, ts') = res in (b2t b ==> isConstantTime (Ins ins) ts.lts) #set-options "--z3rlimit 20"
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tsAnalysis: Vale.X64.Leakage_Helpers.analysis_taints -> tsExpected: Vale.X64.Leakage_Helpers.analysis_taints -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.analysis_taints", "Prims.op_BarBar", "Prims.op_AmpAmp", "Prims.op_Equality", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_s.__proj__LeakageTaints__item__flagsTaint", "Vale.X64.Leakage_Helpers.__proj__AnalysisTaints__item__lts", "Vale.Arch.HeapTypes_s.Public", "Vale.Arch.HeapTypes_s.Secret", "Prims.bool" ]
[]
false
false
false
true
false
let publicFlagValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool =
(tsExpected.lts.flagsTaint = Public && tsAnalysis.lts.flagsTaint = Public) || (tsExpected.lts.flagsTaint = Secret)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.operand_taint_implicit
val operand_taint_implicit (i: instr_operand_implicit) (ts: analysis_taints) : taint
val operand_taint_implicit (i: instr_operand_implicit) (ts: analysis_taints) : taint
let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 72, "start_col": 0, "start_line": 64 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Instruction_s.instr_operand_implicit -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> Vale.Arch.HeapTypes_s.taint
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.X64.Machine_s.operand64", "Vale.X64.Leakage_Helpers.operand_taint", "Vale.X64.Machine_s.operand128", "Vale.X64.Leakage_s.__proj__LeakageTaints__item__cfFlagsTaint", "Vale.X64.Leakage_Helpers.__proj__AnalysisTaints__item__lts", "Vale.X64.Leakage_s.__proj__LeakageTaints__item__ofFlagsTaint", "Vale.Arch.HeapTypes_s.taint" ]
[]
false
false
false
true
false
let operand_taint_implicit (i: instr_operand_implicit) (ts: analysis_taints) : taint =
match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.publicOfFlagValuesAreAsExpected
val publicOfFlagValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
val publicOfFlagValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
let publicOfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.ofFlagsTaint = Public && tsAnalysis.lts.ofFlagsTaint = Public) || (tsExpected.lts.ofFlagsTaint = Secret)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 122, "end_line": 166, "start_col": 0, "start_line": 165 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts let ins_consumes_fixed_time (ins:ins) (ts:analysis_taints) (res:bool & analysis_taints) = let (b, ts') = res in (b2t b ==> isConstantTime (Ins ins) ts.lts) #set-options "--z3rlimit 20" let publicFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.flagsTaint = Public && tsAnalysis.lts.flagsTaint = Public) || (tsExpected.lts.flagsTaint = Secret) let publicCfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.cfFlagsTaint = Public && tsAnalysis.lts.cfFlagsTaint = Public) || (tsExpected.lts.cfFlagsTaint = Secret)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tsAnalysis: Vale.X64.Leakage_Helpers.analysis_taints -> tsExpected: Vale.X64.Leakage_Helpers.analysis_taints -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.analysis_taints", "Prims.op_BarBar", "Prims.op_AmpAmp", "Prims.op_Equality", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_s.__proj__LeakageTaints__item__ofFlagsTaint", "Vale.X64.Leakage_Helpers.__proj__AnalysisTaints__item__lts", "Vale.Arch.HeapTypes_s.Public", "Vale.Arch.HeapTypes_s.Secret", "Prims.bool" ]
[]
false
false
false
true
false
let publicOfFlagValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool =
(tsExpected.lts.ofFlagsTaint = Public && tsAnalysis.lts.ofFlagsTaint = Public) || (tsExpected.lts.ofFlagsTaint = Secret)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.args_taint
val args_taint (args: list instr_operand) (oprs: instr_operands_t_args args) (ts: analysis_taints) : taint
val args_taint (args: list instr_operand) (oprs: instr_operands_t_args args) (ts: analysis_taints) : taint
let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 91, "start_col": 0, "start_line": 75 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
args: Prims.list Vale.X64.Instruction_s.instr_operand -> oprs: Vale.X64.Instruction_s.instr_operands_t_args args -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> Vale.Arch.HeapTypes_s.taint
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_operands_t_args", "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Leakage_Helpers.merge_taint", "Vale.X64.Leakage_Helpers.operand_taint_explicit", "FStar.Pervasives.Native.fst", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Leakage_Helpers.args_taint", "FStar.Pervasives.Native.snd", "FStar.Pervasives.Native.tuple2", "Vale.X64.Instruction_s.coerce", "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.X64.Leakage_Helpers.operand_taint_implicit", "Vale.Arch.HeapTypes_s.taint" ]
[ "recursion" ]
false
false
false
false
false
let rec args_taint (args: list instr_operand) (oprs: instr_operands_t_args args) (ts: analysis_taints) : taint =
match args with | [] -> Public | i :: args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.operand_taint
val operand_taint (rf: reg_file_id) (o: operand_rf rf) (ts: analysis_taints) : taint
val operand_taint (rf: reg_file_id) (o: operand_rf rf) (ts: analysis_taints) : taint
let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 51, "start_col": 0, "start_line": 47 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
rf: Vale.X64.Machine_s.reg_file_id -> o: Vale.X64.Machine_s.operand_rf rf -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> Vale.Arch.HeapTypes_s.taint
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.reg_file_id", "Vale.X64.Machine_s.operand_rf", "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.X64.Machine_s.t_reg_file", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Machine_s.reg_id", "Vale.Lib.MapTree.sel", "Vale.X64.Machine_s.reg", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_Helpers.__proj__AnalysisTaints__item__rts", "Vale.X64.Machine_s.Reg", "Vale.X64.Machine_s.maddr" ]
[]
false
false
false
false
false
let operand_taint (rf: reg_file_id) (o: operand_rf rf) (ts: analysis_taints) : taint =
match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.maddr_does_not_use_secrets
val maddr_does_not_use_secrets (addr: maddr) (ts: analysis_taints) : bool
val maddr_does_not_use_secrets (addr: maddr) (ts: analysis_taints) : bool
let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 124, "start_col": 0, "start_line": 117 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
addr: Vale.X64.Machine_s.maddr -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.maddr", "Vale.X64.Leakage_Helpers.analysis_taints", "Prims.int", "Vale.X64.Machine_s.reg", "Vale.Arch.HeapTypes_s.uu___is_Public", "Vale.Lib.MapTree.sel", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_Helpers.__proj__AnalysisTaints__item__rts", "Prims.op_AmpAmp", "Prims.bool" ]
[]
false
false
false
true
false
let maddr_does_not_use_secrets (addr: maddr) (ts: analysis_taints) : bool =
match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.operand_does_not_use_secrets
val operand_does_not_use_secrets (#tc #tr: eqtype) (o: operand tc tr) (ts: analysis_taints) : bool
val operand_does_not_use_secrets (#tc #tr: eqtype) (o: operand tc tr) (ts: analysis_taints) : bool
let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 66, "end_line": 129, "start_col": 0, "start_line": 126 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
o: Vale.X64.Machine_s.operand tc tr -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "Vale.X64.Machine_s.operand", "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_Helpers.maddr_does_not_use_secrets", "Prims.bool" ]
[]
false
false
false
false
false
let operand_does_not_use_secrets (#tc #tr: eqtype) (o: operand tc tr) (ts: analysis_taints) : bool =
match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.operand_taint_explicit
val operand_taint_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (ts: analysis_taints) : taint
val operand_taint_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (ts: analysis_taints) : taint
let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 61, "start_col": 0, "start_line": 54 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Instruction_s.instr_operand_explicit -> o: Vale.X64.Instruction_s.instr_operand_t i -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> Vale.Arch.HeapTypes_s.taint
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.X64.Leakage_Helpers.operand_taint", "Vale.X64.Machine_s.operand64", "Vale.X64.Machine_s.operand128", "Vale.Arch.HeapTypes_s.taint" ]
[]
false
false
false
false
false
let operand_taint_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (ts: analysis_taints) : taint =
match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.inouts_taint
val inouts_taint (inouts: list instr_out) (args: list instr_operand) (oprs: instr_operands_t inouts args) (ts: analysis_taints) : taint
val inouts_taint (inouts: list instr_out) (args: list instr_operand) (oprs: instr_operands_t inouts args) (ts: analysis_taints) : taint
let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 115, "start_col": 0, "start_line": 94 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
inouts: Prims.list Vale.X64.Instruction_s.instr_out -> args: Prims.list Vale.X64.Instruction_s.instr_operand -> oprs: Vale.X64.Instruction_s.instr_operands_t inouts args -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> Vale.Arch.HeapTypes_s.taint
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.X64.Leakage_Helpers.args_taint", "Vale.X64.Leakage_Helpers.inouts_taint", "Vale.X64.Instruction_s.instr_operand_explicit", "FStar.Pervasives.Native.snd", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Instruction_s.coerce", "FStar.Pervasives.Native.tuple2", "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_Helpers.merge_taint", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Leakage_Helpers.operand_taint_explicit", "FStar.Pervasives.Native.fst", "Vale.X64.Leakage_Helpers.operand_taint_implicit" ]
[ "recursion" ]
false
false
false
false
false
let rec inouts_taint (inouts: list instr_out) (args: list instr_operand) (oprs: instr_operands_t inouts args) (ts: analysis_taints) : taint =
match inouts with | [] -> args_taint args oprs ts | (Out, i) :: inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i) :: inouts -> let v, oprs = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.publicTaintsAreAsExpected
val publicTaintsAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
val publicTaintsAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
let publicTaintsAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = publicFlagValuesAreAsExpected tsAnalysis tsExpected && publicCfFlagValuesAreAsExpected tsAnalysis tsExpected && publicOfFlagValuesAreAsExpected tsAnalysis tsExpected && publicRegisterValuesAreAsExpected tsAnalysis tsExpected
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 195, "start_col": 0, "start_line": 191 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts let ins_consumes_fixed_time (ins:ins) (ts:analysis_taints) (res:bool & analysis_taints) = let (b, ts') = res in (b2t b ==> isConstantTime (Ins ins) ts.lts) #set-options "--z3rlimit 20" let publicFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.flagsTaint = Public && tsAnalysis.lts.flagsTaint = Public) || (tsExpected.lts.flagsTaint = Secret) let publicCfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.cfFlagsTaint = Public && tsAnalysis.lts.cfFlagsTaint = Public) || (tsExpected.lts.cfFlagsTaint = Secret) let publicOfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.ofFlagsTaint = Public && tsAnalysis.lts.ofFlagsTaint = Public) || (tsExpected.lts.ofFlagsTaint = Secret) let registerAsExpected (r:reg) (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (sel tsExpected.rts r = Public && sel tsAnalysis.rts r = Public) || (sel tsExpected.rts r = Secret) let rec publicRegisterValuesAreAsExpected_reg_file (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : bool = if k = 0 then true else registerAsExpected (Reg rf (k - 1)) tsAnalysis tsExpected && publicRegisterValuesAreAsExpected_reg_file tsAnalysis tsExpected rf (k - 1) let rec publicRegisterValuesAreAsExpected_regs (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) (k:nat{k <= n_reg_files}) : bool = if k = 0 then true else publicRegisterValuesAreAsExpected_reg_file tsAnalysis tsExpected (k - 1) (n_regs (k - 1)) && publicRegisterValuesAreAsExpected_regs tsAnalysis tsExpected (k - 1) let publicRegisterValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = publicRegisterValuesAreAsExpected_regs tsAnalysis tsExpected n_reg_files
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tsAnalysis: Vale.X64.Leakage_Helpers.analysis_taints -> tsExpected: Vale.X64.Leakage_Helpers.analysis_taints -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.analysis_taints", "Prims.op_AmpAmp", "Vale.X64.Leakage_Helpers.publicFlagValuesAreAsExpected", "Vale.X64.Leakage_Helpers.publicCfFlagValuesAreAsExpected", "Vale.X64.Leakage_Helpers.publicOfFlagValuesAreAsExpected", "Vale.X64.Leakage_Helpers.publicRegisterValuesAreAsExpected", "Prims.bool" ]
[]
false
false
false
true
false
let publicTaintsAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool =
publicFlagValuesAreAsExpected tsAnalysis tsExpected && publicCfFlagValuesAreAsExpected tsAnalysis tsExpected && publicOfFlagValuesAreAsExpected tsAnalysis tsExpected && publicRegisterValuesAreAsExpected tsAnalysis tsExpected
false
Steel.PCMReference.fst
Steel.PCMReference.recall
val recall (#inames: _) (#a:Type u#1) (#pcm:pcm a) (fact:property a) (r:erased (ref a pcm)) (v:erased a) (w:witnessed r fact) : SteelAtomicU (erased a) inames (pts_to r v) (fun v1 -> pts_to r v) (requires fun _ -> True) (ensures fun _ v1 _ -> fact v1 /\ compatible pcm v v1)
val recall (#inames: _) (#a:Type u#1) (#pcm:pcm a) (fact:property a) (r:erased (ref a pcm)) (v:erased a) (w:witnessed r fact) : SteelAtomicU (erased a) inames (pts_to r v) (fun v1 -> pts_to r v) (requires fun _ -> True) (ensures fun _ v1 _ -> fact v1 /\ compatible pcm v v1)
let recall #inames #a #pcm fact r v w = let v1 = recall' fact r v w in rewrite_slprop (to_vprop Mem.(pts_to r v `star` pure (fact v1))) (pts_to r v `star` pure (fact v1)) (fun _ -> ()); elim_pure (fact v1); v1
{ "file_name": "lib/steel/Steel.PCMReference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 4, "end_line": 111, "start_col": 0, "start_line": 105 }
(* Copyright 2020 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 Steel.PCMReference module Mem = Steel.Memory let read r v0 = let v = as_action (sel_action FStar.Set.empty r v0) in v let write r v0 v1 = as_action (upd_action FStar.Set.empty r v0 v1) val alloc' (#a:Type) (#pcm:pcm a) (x:a) : Steel (ref a pcm) (to_vprop Mem.emp) (fun r -> pts_to r x) (requires fun _ -> compatible pcm x x /\ pcm.refine x) (ensures fun _ _ _ -> True) let alloc' x = as_action (alloc_action FStar.Set.empty x) let alloc #_ #pcm x = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); compatible_refl pcm x; alloc' x let free r x = as_action (free_action FStar.Set.empty r x) val split' (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v0:erased a) (v1:erased a{composable p v0 v1}) : SteelGhostT unit inames (pts_to r (op p v0 v1)) (fun _ -> to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) let split' #inames #a #p r v0 v1 = as_atomic_action_ghost (split_action inames r v0 v1) let split #_ #a #p r v v0 v1 = let _:squash (composable p v0 v1) = () in rewrite_slprop (pts_to r v) (pts_to r (op p v0 v1)) (fun _ -> ()); split' r v0 v1; rewrite_slprop (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (pts_to r v0 `star` pts_to r v1) (fun _ -> ()) val gather' (#inames: _) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:erased a) (v1:erased a) : SteelGhostT (_:unit{composable p v0 v1}) inames (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (fun _ -> pts_to r (op p v0 v1)) let gather' #inames r v0 v1 = as_atomic_action_ghost (gather_action inames r v0 v1) let gather r v0 v1 = rewrite_slprop (pts_to r v0 `star` pts_to r v1) (to_vprop Mem.(pts_to r v0 `star` pts_to r v1)) (fun _ -> ()); gather' r v0 v1 val witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:erased (ref a pcm)) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) : SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> to_vprop Mem.(pts_to r v)) let witness' #inames r fact v _ = as_atomic_unobservable_action (Steel.Memory.witness inames r fact v ()) let witness r fact v s = let w = witness' r fact v s in w val recall' (#inames: _) (#a:Type u#1) (#pcm:pcm a) (fact:property a) (r:erased (ref a pcm)) (v:erased a) (w:witnessed r fact) : SteelAtomicUT (v1:erased a{compatible pcm v v1}) inames (to_vprop Mem.(pts_to r v)) (fun v1 -> to_vprop Mem.(pts_to r v `star` pure (fact v1))) let recall' #inames #a #pcm fact r v w = as_atomic_unobservable_action (Steel.Memory.recall #a #pcm #fact inames r v w)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked" ], "interface_file": true, "source_file": "Steel.PCMReference.fst" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
fact: Steel.Memory.property a -> r: FStar.Ghost.erased (Steel.Memory.ref a pcm) -> v: FStar.Ghost.erased a -> w: Steel.Memory.witnessed (FStar.Ghost.reveal r) fact -> Steel.Effect.Atomic.SteelAtomicU (FStar.Ghost.erased a)
Steel.Effect.Atomic.SteelAtomicU
[]
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.property", "FStar.Ghost.erased", "Steel.Memory.ref", "Steel.Memory.witnessed", "FStar.Ghost.reveal", "Prims.unit", "Steel.Effect.Atomic.elim_pure", "Steel.Effect.Atomic.rewrite_slprop", "Steel.Effect.Common.to_vprop", "Steel.Memory.star", "Steel.Memory.pts_to", "Steel.Memory.pure", "Steel.Effect.Common.star", "Steel.PCMReference.pts_to", "Steel.Effect.Common.pure", "Steel.Memory.mem", "FStar.PCM.compatible", "Steel.PCMReference.recall'" ]
[]
false
true
false
false
false
let recall #inames #a #pcm fact r v w =
let v1 = recall' fact r v w in rewrite_slprop (to_vprop Mem.((pts_to r v) `star` (pure (fact v1)))) ((pts_to r v) `star` (pure (fact v1))) (fun _ -> ()); elim_pure (fact v1); v1
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.regs_to_map_rec
val regs_to_map_rec (rs: reg_taint) (f n: nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r: reg). {:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f;n])
val regs_to_map_rec (rs: reg_taint) (f n: nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r: reg). {:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f;n])
let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 34, "start_col": 0, "start_line": 22 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
rs: Vale.X64.Leakage_s.reg_taint -> f: Prims.nat -> n: Prims.nat -> Prims.Pure Vale.X64.Leakage_Helpers.regmap
Prims.Pure
[ "" ]
[]
[ "Vale.X64.Leakage_s.reg_taint", "Prims.nat", "Prims.op_Equality", "Prims.int", "Vale.Lib.MapTree.const", "Vale.X64.Machine_s.reg", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_Helpers.reg_le", "Vale.Arch.HeapTypes_s.Secret", "Prims.bool", "Vale.X64.Leakage_Helpers.regs_to_map_rec", "Prims.op_Subtraction", "Vale.X64.Machine_s.n_regs", "Vale.X64.Leakage_Helpers.regmap", "Vale.Lib.MapTree.upd", "Vale.X64.Machine_s.Reg", "Prims.l_or", "Prims.l_and", "Prims.eq2", "Vale.X64.Machine_s.n_reg_files", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Prims.l_Forall", "Prims.l_imp", "Vale.X64.Machine_s.__proj__Reg__item__rf", "Vale.X64.Machine_s.__proj__Reg__item__r", "Vale.Lib.MapTree.sel" ]
[ "recursion" ]
false
false
false
false
false
let rec regs_to_map_rec (rs: reg_taint) (f n: nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r: reg). {:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f;n]) =
if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.set_taint
val set_taint (rf: reg_file_id) (dst: operand_rf rf) (ts: analysis_taints) (t: taint) : analysis_taints
val set_taint (rf: reg_file_id) (dst: operand_rf rf) (ts: analysis_taints) (t: taint) : analysis_taints
let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 143, "start_col": 0, "start_line": 136 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
rf: Vale.X64.Machine_s.reg_file_id -> dst: Vale.X64.Machine_s.operand_rf rf -> ts: Vale.X64.Leakage_Helpers.analysis_taints -> t: Vale.Arch.HeapTypes_s.taint -> Vale.X64.Leakage_Helpers.analysis_taints
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.reg_file_id", "Vale.X64.Machine_s.operand_rf", "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_s.t_reg_file", "Vale.X64.Machine_s.reg_id", "Vale.X64.Leakage_s.reg_taint", "Vale.X64.Leakage_Helpers.regmap", "Vale.X64.Leakage_Helpers.is_map_of", "Vale.X64.Leakage_s.__proj__LeakageTaints__item__regTaint", "Vale.X64.Leakage_s.LeakageTaints", "Vale.X64.Leakage_Helpers.AnalysisTaints", "Vale.X64.Leakage_Helpers.map_to_regs", "Vale.Lib.MapTree.map", "Vale.X64.Machine_s.reg", "Vale.Lib.MapTree.upd", "Vale.X64.Machine_s.Reg", "Vale.X64.Machine_s.tmaddr" ]
[]
false
false
false
false
false
let set_taint (rf: reg_file_id) (dst: operand_rf rf) (ts: analysis_taints) (t: taint) : analysis_taints =
match dst with | OConst _ -> ts | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.set_taint_cf_and_flags
val set_taint_cf_and_flags (ts: analysis_taints) (t: taint) : analysis_taints
val set_taint_cf_and_flags (ts: analysis_taints) (t: taint) : analysis_taints
let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 67, "end_line": 147, "start_col": 0, "start_line": 145 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
ts: Vale.X64.Leakage_Helpers.analysis_taints -> t: Vale.Arch.HeapTypes_s.taint -> Vale.X64.Leakage_Helpers.analysis_taints
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_s.reg_taint", "Vale.X64.Leakage_Helpers.regmap", "Vale.X64.Leakage_Helpers.is_map_of", "Vale.X64.Leakage_s.__proj__LeakageTaints__item__regTaint", "Vale.X64.Leakage_s.LeakageTaints", "Vale.X64.Leakage_Helpers.AnalysisTaints", "Vale.X64.Leakage_Helpers.merge_taint" ]
[]
false
false
false
true
false
let set_taint_cf_and_flags (ts: analysis_taints) (t: taint) : analysis_taints =
let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.operand_taint_allowed
val operand_taint_allowed (#tc #tr: eqtype) (o: operand tc tr) (t_data: taint) : bool
val operand_taint_allowed (#tc #tr: eqtype) (o: operand tc tr) (t_data: taint) : bool
let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 88, "end_line": 134, "start_col": 0, "start_line": 131 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
o: Vale.X64.Machine_s.operand tc tr -> t_data: Vale.Arch.HeapTypes_s.taint -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "Vale.X64.Machine_s.operand", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_s.maddr", "Prims.op_BarBar", "Prims.op_Equality", "Vale.Arch.HeapTypes_s.Secret", "Vale.Arch.HeapTypes_s.Public", "Prims.bool" ]
[]
false
false
false
false
false
let operand_taint_allowed (#tc #tr: eqtype) (o: operand tc tr) (t_data: taint) : bool =
match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public
false
MiniParseExample2.fst
MiniParseExample2.imp0
val imp0 (x: somme) : Tot (bounded_u16 4)
val imp0 (x: somme) : Tot (bounded_u16 4)
let imp0 (x: somme) : Tot (bounded_u16 4) = match x with | U _ -> 0us <: bounded_u16 4 | V -> 1us <: bounded_u16 4 | W -> 2us <: bounded_u16 4 | _ -> 3us <: bounded_u16 4
{ "file_name": "examples/miniparse/MiniParseExample2.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 31, "start_col": 2, "start_line": 27 }
(* 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 MiniParseExample2 open MiniParse.Spec.TSum module T = FStar.Tactics.V2 module U8 = FStar.UInt8 noeq type somme = | U of FStar.UInt8.t | V | W | X #set-options "--z3rlimit 16"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.TSum.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParseExample2.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "MiniParse.Spec.TSum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: MiniParseExample2.somme -> MiniParse.Spec.Int.bounded_u16 4
Prims.Tot
[ "total" ]
[]
[ "MiniParseExample2.somme", "FStar.UInt8.t", "FStar.UInt16.__uint_to_t", "MiniParse.Spec.Int.bounded_u16" ]
[]
false
false
false
false
false
let imp0 (x: somme) : Tot (bounded_u16 4) =
match x with | U _ -> 0us <: bounded_u16 4 | V -> 1us <: bounded_u16 4 | W -> 2us <: bounded_u16 4 | _ -> 3us <: bounded_u16 4
false
FStar.Option.fst
FStar.Option.isNone
val isNone: option 'a -> Tot bool
val isNone: option 'a -> Tot bool
let isNone = function | None -> true | Some _ -> false
{ "file_name": "ulib/FStar.Option.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 25, "start_col": 0, "start_line": 23 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Option open FStar.All inline_for_extraction val isNone: option 'a -> Tot bool
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.Option.fst" }
[ { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: FStar.Pervasives.Native.option 'a -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.option", "Prims.bool" ]
[]
false
false
false
true
false
let isNone =
function | None -> true | Some _ -> false
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.set_taint_of_and_flags
val set_taint_of_and_flags (ts: analysis_taints) (t: taint) : analysis_taints
val set_taint_of_and_flags (ts: analysis_taints) (t: taint) : analysis_taints
let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 66, "end_line": 151, "start_col": 0, "start_line": 149 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
ts: Vale.X64.Leakage_Helpers.analysis_taints -> t: Vale.Arch.HeapTypes_s.taint -> Vale.X64.Leakage_Helpers.analysis_taints
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Leakage_s.reg_taint", "Vale.X64.Leakage_Helpers.regmap", "Vale.X64.Leakage_Helpers.is_map_of", "Vale.X64.Leakage_s.__proj__LeakageTaints__item__regTaint", "Vale.X64.Leakage_s.LeakageTaints", "Vale.X64.Leakage_Helpers.AnalysisTaints", "Vale.X64.Leakage_Helpers.merge_taint" ]
[]
false
false
false
true
false
let set_taint_of_and_flags (ts: analysis_taints) (t: taint) : analysis_taints =
let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts
false
FStar.Buffer.Quantifiers.fst
FStar.Buffer.Quantifiers.lemma_offset_quantifiers
val lemma_offset_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t{v i <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b' /\ length b' = length b - v i /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (length b)); SMTPat (as_seq h b')]
val lemma_offset_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t{v i <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b' /\ length b' = length b - v i /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (length b)); SMTPat (as_seq h b')]
let lemma_offset_quantifiers #a h b b' i = lemma_sub_quantifiers #a h b b' i (uint_to_t (length b - v i))
{ "file_name": "ulib/legacy/FStar.Buffer.Quantifiers.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 47, "start_col": 0, "start_line": 46 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer.Quantifiers open FStar.Seq open FStar.UInt32 open FStar.HyperStack open FStar.Ghost open FStar.Buffer open FStar.Classical #set-options "--initial_fuel 0 --max_fuel 0" val lemma_sub_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t -> len:FStar.UInt32.t{v len <= length b /\ v i + v len <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b' /\ length b' = v len /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (v i + v len)); SMTPat (as_seq h b')] let lemma_sub_quantifiers #a h b b' i len = assert (Seq.length (Seq.slice (as_seq h b) (v i) (v i + v len)) = v len); let lemma_post (j:nat) = j < length b' ==> get h b' j == get h b (j + v i) in let qj : j:nat -> Lemma (lemma_post j) = fun j -> assert (j < v len ==> Seq.index (as_seq h b') j == Seq.index (as_seq h b) (j + v i)) in Classical.forall_intro #_ #lemma_post qj val lemma_offset_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t{v i <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b' /\ length b' = length b - v i /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) ))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Buffer.fst.checked" ], "interface_file": false, "source_file": "FStar.Buffer.Quantifiers.fst" }
[ { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 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: FStar.Buffer.buffer a -> b': FStar.Buffer.buffer a -> i: FStar.UInt32.t{FStar.UInt32.v i <= FStar.Buffer.length b} -> FStar.Pervasives.Lemma (requires FStar.Buffer.live h b /\ FStar.Buffer.live h b' /\ FStar.Seq.Base.slice (FStar.Buffer.as_seq h b) (FStar.UInt32.v i) (FStar.Buffer.length b) == FStar.Buffer.as_seq h b') (ensures FStar.Buffer.live h b /\ FStar.Buffer.live h b' /\ FStar.Seq.Base.slice (FStar.Buffer.as_seq h b) (FStar.UInt32.v i) (FStar.Buffer.length b) == FStar.Buffer.as_seq h b' /\ FStar.Buffer.length b' = FStar.Buffer.length b - FStar.UInt32.v i /\ (forall (j: Prims.nat). {:pattern FStar.Buffer.get h b' j} j < FStar.Buffer.length b' ==> FStar.Buffer.get h b' j == FStar.Buffer.get h b (j + FStar.UInt32.v i))) [ SMTPat (FStar.Seq.Base.slice (FStar.Buffer.as_seq h b) (FStar.UInt32.v i) (FStar.Buffer.length b)); SMTPat (FStar.Buffer.as_seq h b') ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.buffer", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "FStar.Buffer.length", "FStar.Buffer.Quantifiers.lemma_sub_quantifiers", "FStar.UInt32.uint_to_t", "Prims.op_Subtraction", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_offset_quantifiers #a h b b' i =
lemma_sub_quantifiers #a h b b' i (uint_to_t (length b - v i))
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.registerAsExpected
val registerAsExpected (r: reg) (tsAnalysis tsExpected: analysis_taints) : bool
val registerAsExpected (r: reg) (tsAnalysis tsExpected: analysis_taints) : bool
let registerAsExpected (r:reg) (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (sel tsExpected.rts r = Public && sel tsAnalysis.rts r = Public) || (sel tsExpected.rts r = Secret)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 101, "end_line": 169, "start_col": 0, "start_line": 168 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts let ins_consumes_fixed_time (ins:ins) (ts:analysis_taints) (res:bool & analysis_taints) = let (b, ts') = res in (b2t b ==> isConstantTime (Ins ins) ts.lts) #set-options "--z3rlimit 20" let publicFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.flagsTaint = Public && tsAnalysis.lts.flagsTaint = Public) || (tsExpected.lts.flagsTaint = Secret) let publicCfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.cfFlagsTaint = Public && tsAnalysis.lts.cfFlagsTaint = Public) || (tsExpected.lts.cfFlagsTaint = Secret) let publicOfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.ofFlagsTaint = Public && tsAnalysis.lts.ofFlagsTaint = Public) || (tsExpected.lts.ofFlagsTaint = Secret)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Vale.X64.Machine_s.reg -> tsAnalysis: Vale.X64.Leakage_Helpers.analysis_taints -> tsExpected: Vale.X64.Leakage_Helpers.analysis_taints -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.reg", "Vale.X64.Leakage_Helpers.analysis_taints", "Prims.op_BarBar", "Prims.op_AmpAmp", "Prims.op_Equality", "Vale.Arch.HeapTypes_s.taint", "Vale.Lib.MapTree.sel", "Vale.X64.Leakage_Helpers.__proj__AnalysisTaints__item__rts", "Vale.Arch.HeapTypes_s.Public", "Vale.Arch.HeapTypes_s.Secret", "Prims.bool" ]
[]
false
false
false
true
false
let registerAsExpected (r: reg) (tsAnalysis tsExpected: analysis_taints) : bool =
(sel tsExpected.rts r = Public && sel tsAnalysis.rts r = Public) || (sel tsExpected.rts r = Secret)
false
FStar.Option.fst
FStar.Option.mapTot
val mapTot: ('a -> Tot 'b) -> option 'a -> Tot (option 'b)
val mapTot: ('a -> Tot 'b) -> option 'a -> Tot (option 'b)
let mapTot f = function | Some x -> Some (f x) | None -> None
{ "file_name": "ulib/FStar.Option.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 46, "start_col": 0, "start_line": 44 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Option open FStar.All inline_for_extraction val isNone: option 'a -> Tot bool inline_for_extraction let isNone = function | None -> true | Some _ -> false inline_for_extraction val isSome: option 'a -> Tot bool inline_for_extraction let isSome = function | Some _ -> true | None -> false inline_for_extraction val map: ('a -> ML 'b) -> option 'a -> ML (option 'b) inline_for_extraction let map f = function | Some x -> Some (f x) | None -> None inline_for_extraction val mapTot: ('a -> Tot 'b) -> option 'a -> Tot (option 'b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.Option.fst" }
[ { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> 'b) -> _: FStar.Pervasives.Native.option 'a -> FStar.Pervasives.Native.option 'b
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.None" ]
[]
false
false
false
true
false
let mapTot f =
function | Some x -> Some (f x) | None -> None
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.publicRegisterValuesAreAsExpected_regs
val publicRegisterValuesAreAsExpected_regs (tsAnalysis tsExpected: analysis_taints) (k: nat{k <= n_reg_files}) : bool
val publicRegisterValuesAreAsExpected_regs (tsAnalysis tsExpected: analysis_taints) (k: nat{k <= n_reg_files}) : bool
let rec publicRegisterValuesAreAsExpected_regs (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) (k:nat{k <= n_reg_files}) : bool = if k = 0 then true else publicRegisterValuesAreAsExpected_reg_file tsAnalysis tsExpected (k - 1) (n_regs (k - 1)) && publicRegisterValuesAreAsExpected_regs tsAnalysis tsExpected (k - 1)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 72, "end_line": 185, "start_col": 0, "start_line": 179 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts let ins_consumes_fixed_time (ins:ins) (ts:analysis_taints) (res:bool & analysis_taints) = let (b, ts') = res in (b2t b ==> isConstantTime (Ins ins) ts.lts) #set-options "--z3rlimit 20" let publicFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.flagsTaint = Public && tsAnalysis.lts.flagsTaint = Public) || (tsExpected.lts.flagsTaint = Secret) let publicCfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.cfFlagsTaint = Public && tsAnalysis.lts.cfFlagsTaint = Public) || (tsExpected.lts.cfFlagsTaint = Secret) let publicOfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.ofFlagsTaint = Public && tsAnalysis.lts.ofFlagsTaint = Public) || (tsExpected.lts.ofFlagsTaint = Secret) let registerAsExpected (r:reg) (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (sel tsExpected.rts r = Public && sel tsAnalysis.rts r = Public) || (sel tsExpected.rts r = Secret) let rec publicRegisterValuesAreAsExpected_reg_file (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : bool = if k = 0 then true else registerAsExpected (Reg rf (k - 1)) tsAnalysis tsExpected && publicRegisterValuesAreAsExpected_reg_file tsAnalysis tsExpected rf (k - 1)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tsAnalysis: Vale.X64.Leakage_Helpers.analysis_taints -> tsExpected: Vale.X64.Leakage_Helpers.analysis_taints -> k: Prims.nat{k <= Vale.X64.Machine_s.n_reg_files} -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.analysis_taints", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Vale.X64.Machine_s.n_reg_files", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.op_AmpAmp", "Vale.X64.Leakage_Helpers.publicRegisterValuesAreAsExpected_reg_file", "Prims.op_Subtraction", "Vale.X64.Machine_s.n_regs", "Vale.X64.Leakage_Helpers.publicRegisterValuesAreAsExpected_regs" ]
[ "recursion" ]
false
false
false
false
false
let rec publicRegisterValuesAreAsExpected_regs (tsAnalysis tsExpected: analysis_taints) (k: nat{k <= n_reg_files}) : bool =
if k = 0 then true else publicRegisterValuesAreAsExpected_reg_file tsAnalysis tsExpected (k - 1) (n_regs (k - 1)) && publicRegisterValuesAreAsExpected_regs tsAnalysis tsExpected (k - 1)
false
FStar.Option.fst
FStar.Option.map
val map: ('a -> ML 'b) -> option 'a -> ML (option 'b)
val map: ('a -> ML 'b) -> option 'a -> ML (option 'b)
let map f = function | Some x -> Some (f x) | None -> None
{ "file_name": "ulib/FStar.Option.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 39, "start_col": 0, "start_line": 37 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Option open FStar.All inline_for_extraction val isNone: option 'a -> Tot bool inline_for_extraction let isNone = function | None -> true | Some _ -> false inline_for_extraction val isSome: option 'a -> Tot bool inline_for_extraction let isSome = function | Some _ -> true | None -> false inline_for_extraction val map: ('a -> ML 'b) -> option 'a -> ML (option 'b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.Option.fst" }
[ { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.All.ML 'b) -> _: FStar.Pervasives.Native.option 'a -> FStar.All.ML (FStar.Pervasives.Native.option 'b)
FStar.All.ML
[ "ml" ]
[]
[ "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.None" ]
[]
false
true
false
false
false
let map f =
function | Some x -> Some (f x) | None -> None
false
FStar.Option.fst
FStar.Option.isSome
val isSome: option 'a -> Tot bool
val isSome: option 'a -> Tot bool
let isSome = function | Some _ -> true | None -> false
{ "file_name": "ulib/FStar.Option.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 32, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Option open FStar.All inline_for_extraction val isNone: option 'a -> Tot bool inline_for_extraction let isNone = function | None -> true | Some _ -> false inline_for_extraction val isSome: option 'a -> Tot bool
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.Option.fst" }
[ { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: FStar.Pervasives.Native.option 'a -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.option", "Prims.bool" ]
[]
false
false
false
true
false
let isSome =
function | Some _ -> true | None -> false
false
FStar.Option.fst
FStar.Option.get
val get: option 'a -> ML 'a
val get: option 'a -> ML 'a
let get = function | Some x -> x | None -> failwith "empty option"
{ "file_name": "ulib/FStar.Option.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 52, "start_col": 0, "start_line": 50 }
(* Copyright 2008-2014 Nikhil Swamy and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Option open FStar.All inline_for_extraction val isNone: option 'a -> Tot bool inline_for_extraction let isNone = function | None -> true | Some _ -> false inline_for_extraction val isSome: option 'a -> Tot bool inline_for_extraction let isSome = function | Some _ -> true | None -> false inline_for_extraction val map: ('a -> ML 'b) -> option 'a -> ML (option 'b) inline_for_extraction let map f = function | Some x -> Some (f x) | None -> None inline_for_extraction val mapTot: ('a -> Tot 'b) -> option 'a -> Tot (option 'b) inline_for_extraction let mapTot f = function | Some x -> Some (f x) | None -> None inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.Option.fst" }
[ { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: FStar.Pervasives.Native.option 'a -> FStar.All.ML 'a
FStar.All.ML
[ "ml" ]
[]
[ "FStar.Pervasives.Native.option", "FStar.All.failwith" ]
[]
false
true
false
false
false
let get =
function | Some x -> x | None -> failwith "empty option"
false
MiniParseExample2.fst
MiniParseExample2.imp1
val imp1 (x: bounded_u16 4) : Tot (sum_case #somme #(bounded_u16 4) imp0 x)
val imp1 (x: bounded_u16 4) : Tot (sum_case #somme #(bounded_u16 4) imp0 x)
let imp1 : (x: bounded_u16 4) -> Tot (sum_case #somme #(bounded_u16 4) imp0 x) = (bounded_u16_match_t_intro 4 imp0 ( bounded_u16_match_t_aux_cons 4 imp0 3 3us ( c3 ) ( bounded_u16_match_t_aux_cons 4 imp0 2 2us ( c2 ) ( bounded_u16_match_t_aux_cons 4 imp0 1 1us ( c1 ) ( bounded_u16_match_t_aux_cons_nil 4 imp0 ( c0 ))))))
{ "file_name": "examples/miniparse/MiniParseExample2.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 91, "start_col": 0, "start_line": 78 }
(* 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 MiniParseExample2 open MiniParse.Spec.TSum module T = FStar.Tactics.V2 module U8 = FStar.UInt8 noeq type somme = | U of FStar.UInt8.t | V | W | X #set-options "--z3rlimit 16" let imp0 (x: somme) : Tot (bounded_u16 4) = match x with | U _ -> 0us <: bounded_u16 4 | V -> 1us <: bounded_u16 4 | W -> 2us <: bounded_u16 4 | _ -> 3us <: bounded_u16 4 #set-options "--print_universes --print_implicits" let c3 : sum_case #somme #(bounded_u16 4) imp0 3us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> X <: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) -> ()) () #set-options "--z3rlimit 64" let c2 : sum_case #somme #(bounded_u16 4) imp0 2us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> W <: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) -> ()) () let c1 : sum_case #somme #(bounded_u16 4) imp0 1us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> V <: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) -> ()) () let c0 : sum_case #somme #(bounded_u16 4) imp0 0us = Case #(bounded_u16 4) #somme U8.t parse_u8 serialize_u8 (fun (x: U8.t) -> U x <: refine_with_tag #(bounded_u16 4) #somme imp0 (0us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 0us) -> ( match x with | U x -> x )) () #reset-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.TSum.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParseExample2.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "MiniParse.Spec.TSum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: MiniParse.Spec.Int.bounded_u16 4 -> MiniParse.Spec.TSum.sum_case MiniParseExample2.imp0 x
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.TSum.bounded_u16_match_t_intro", "MiniParseExample2.somme", "MiniParseExample2.imp0", "MiniParse.Spec.TSum.bounded_u16_match_t_aux_cons", "FStar.UInt16.__uint_to_t", "MiniParseExample2.c3", "MiniParseExample2.c2", "MiniParseExample2.c1", "MiniParse.Spec.TSum.bounded_u16_match_t_aux_cons_nil", "MiniParseExample2.c0" ]
[]
false
false
false
false
false
let imp1: x: bounded_u16 4 -> Tot (sum_case #somme #(bounded_u16 4) imp0 x) =
(bounded_u16_match_t_intro 4 imp0 (bounded_u16_match_t_aux_cons 4 imp0 3 3us (c3) (bounded_u16_match_t_aux_cons 4 imp0 2 2us (c2) (bounded_u16_match_t_aux_cons 4 imp0 1 1us (c1) (bounded_u16_match_t_aux_cons_nil 4 imp0 (c0))))))
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.publicRegisterValuesAreAsExpected_reg_file
val publicRegisterValuesAreAsExpected_reg_file (tsAnalysis tsExpected: analysis_taints) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : bool
val publicRegisterValuesAreAsExpected_reg_file (tsAnalysis tsExpected: analysis_taints) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : bool
let rec publicRegisterValuesAreAsExpected_reg_file (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : bool = if k = 0 then true else registerAsExpected (Reg rf (k - 1)) tsAnalysis tsExpected && publicRegisterValuesAreAsExpected_reg_file tsAnalysis tsExpected rf (k - 1)
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 79, "end_line": 177, "start_col": 0, "start_line": 171 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts let ins_consumes_fixed_time (ins:ins) (ts:analysis_taints) (res:bool & analysis_taints) = let (b, ts') = res in (b2t b ==> isConstantTime (Ins ins) ts.lts) #set-options "--z3rlimit 20" let publicFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.flagsTaint = Public && tsAnalysis.lts.flagsTaint = Public) || (tsExpected.lts.flagsTaint = Secret) let publicCfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.cfFlagsTaint = Public && tsAnalysis.lts.cfFlagsTaint = Public) || (tsExpected.lts.cfFlagsTaint = Secret) let publicOfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.ofFlagsTaint = Public && tsAnalysis.lts.ofFlagsTaint = Public) || (tsExpected.lts.ofFlagsTaint = Secret) let registerAsExpected (r:reg) (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (sel tsExpected.rts r = Public && sel tsAnalysis.rts r = Public) || (sel tsExpected.rts r = Secret)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tsAnalysis: Vale.X64.Leakage_Helpers.analysis_taints -> tsExpected: Vale.X64.Leakage_Helpers.analysis_taints -> rf: Vale.X64.Machine_s.reg_file_id -> k: Prims.nat{k <= Vale.X64.Machine_s.n_regs rf} -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.X64.Machine_s.reg_file_id", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Vale.X64.Machine_s.n_regs", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.op_AmpAmp", "Vale.X64.Leakage_Helpers.registerAsExpected", "Vale.X64.Machine_s.Reg", "Prims.op_Subtraction", "Vale.X64.Leakage_Helpers.publicRegisterValuesAreAsExpected_reg_file" ]
[ "recursion" ]
false
false
false
false
false
let rec publicRegisterValuesAreAsExpected_reg_file (tsAnalysis tsExpected: analysis_taints) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : bool =
if k = 0 then true else registerAsExpected (Reg rf (k - 1)) tsAnalysis tsExpected && publicRegisterValuesAreAsExpected_reg_file tsAnalysis tsExpected rf (k - 1)
false
Vale.X64.Leakage_Helpers.fst
Vale.X64.Leakage_Helpers.publicRegisterValuesAreAsExpected
val publicRegisterValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
val publicRegisterValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool
let publicRegisterValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = publicRegisterValuesAreAsExpected_regs tsAnalysis tsExpected n_reg_files
{ "file_name": "vale/code/arch/x64/Vale.X64.Leakage_Helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 74, "end_line": 188, "start_col": 0, "start_line": 187 }
module Vale.X64.Leakage_Helpers open FStar.Mul open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Leakage_s open Vale.X64.Instruction_s open Vale.Lib.MapTree let regmap = map reg taint let reg_le (r1 r2:reg) : bool = let Reg f1 n1 = r1 in let Reg f2 n2 = r2 in f1 < f2 || (f1 = f2 && n1 <= n2) let map_to_regs (m:regmap) : reg_taint = FunctionalExtensionality.on reg (sel m) let is_map_of (m:regmap) (rs:reg_taint) = FStar.FunctionalExtensionality.feq (map_to_regs m) rs let rec regs_to_map_rec (rs:reg_taint) (f n:nat) : Pure regmap (requires (f == n_reg_files /\ n == 0) \/ (f < n_reg_files /\ n <= n_regs f)) (ensures (fun m -> forall (r:reg).{:pattern sel m r} r.rf < f \/ (r.rf == f /\ r.r < n) ==> sel m r == rs r)) (decreases %[f; n]) = if n = 0 then if f = 0 then const reg taint reg_le Secret else regs_to_map_rec rs (f - 1) (n_regs (f - 1)) else let m = regs_to_map_rec rs f (n - 1) in let r = Reg f (n - 1) in upd m r (rs r) let regs_to_map (rs:reg_taint) : (m:regmap{is_map_of m rs}) = regs_to_map_rec rs n_reg_files 0 noeq type analysis_taints = | AnalysisTaints: lts:leakage_taints -> rts:regmap{is_map_of rts lts.regTaint} -> analysis_taints let merge_taint (t1:taint) (t2:taint) :taint = if Secret? t1 || Secret? t2 then Secret else Public // Also pass the taint of the instruction let operand_taint (rf:reg_file_id) (o:operand_rf rf) (ts:analysis_taints) : taint = match o with | OConst _ -> Public | OReg r -> sel ts.rts (Reg rf r) | OMem (_, t) | OStack (_, t) -> t [@instr_attr] let operand_taint_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) : taint = match i with | IOp64 -> operand_taint 0 (o <: operand64) ts | IOpXmm -> operand_taint 1 (o <: operand128) ts [@instr_attr] let operand_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) : taint = match i with | IOp64One o -> operand_taint 0 o ts | IOpXmmOne o -> operand_taint 1 o ts | IOpFlagsCf -> ts.lts.cfFlagsTaint | IOpFlagsOf -> ts.lts.ofFlagsTaint [@instr_attr] let rec args_taint (args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints) : taint = match args with | [] -> Public | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in merge_taint (operand_taint_explicit i (fst oprs) ts) (args_taint args (snd oprs) ts) | IOpIm i -> merge_taint (operand_taint_implicit i ts) (args_taint args (coerce oprs) ts) [@instr_attr] let rec inouts_taint (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (ts:analysis_taints) : taint = match inouts with | [] -> args_taint args oprs ts | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in inouts_taint inouts args oprs ts | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in ((operand_taint_explicit i (fst oprs) ts), snd oprs) | IOpIm i -> (operand_taint_implicit i ts, coerce oprs) in merge_taint v (inouts_taint inouts args oprs ts) let maddr_does_not_use_secrets (addr:maddr) (ts:analysis_taints) : bool = match addr with | MConst _ -> true | MReg r _ -> Public? (sel ts.rts r) | MIndex base _ index _ -> let baseTaint = sel ts.rts base in let indexTaint = sel ts.rts index in (Public? baseTaint) && (Public? indexTaint) let operand_does_not_use_secrets (#tc #tr:eqtype) (o:operand tc tr) (ts:analysis_taints) : bool = match o with | OConst _ | OReg _ -> true | OMem (m, _) | OStack (m, _) -> maddr_does_not_use_secrets m ts let operand_taint_allowed (#tc #tr:eqtype) (o:operand tc tr) (t_data:taint) : bool = match o with | OConst _ | OReg _ -> true | OMem (_, t_operand) | OStack (_, t_operand) -> t_operand = Secret || t_data = Public let set_taint (rf:reg_file_id) (dst:operand_rf rf) (ts:analysis_taints) (t:taint) : analysis_taints = match dst with | OConst _ -> ts // Shouldn't actually happen | OReg r -> let AnalysisTaints (LeakageTaints rs f c o) rts = ts in let rts = upd rts (Reg rf r) t in AnalysisTaints (LeakageTaints (map_to_regs rts) f c o) rts | OMem _ | OStack _ -> ts // Ensured by taint semantics let set_taint_cf_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) t ovf) rts let set_taint_of_and_flags (ts:analysis_taints) (t:taint) : analysis_taints = let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in AnalysisTaints (LeakageTaints rs (merge_taint t flags) cf t) rts let ins_consumes_fixed_time (ins:ins) (ts:analysis_taints) (res:bool & analysis_taints) = let (b, ts') = res in (b2t b ==> isConstantTime (Ins ins) ts.lts) #set-options "--z3rlimit 20" let publicFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.flagsTaint = Public && tsAnalysis.lts.flagsTaint = Public) || (tsExpected.lts.flagsTaint = Secret) let publicCfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.cfFlagsTaint = Public && tsAnalysis.lts.cfFlagsTaint = Public) || (tsExpected.lts.cfFlagsTaint = Secret) let publicOfFlagValuesAreAsExpected (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (tsExpected.lts.ofFlagsTaint = Public && tsAnalysis.lts.ofFlagsTaint = Public) || (tsExpected.lts.ofFlagsTaint = Secret) let registerAsExpected (r:reg) (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) : bool = (sel tsExpected.rts r = Public && sel tsAnalysis.rts r = Public) || (sel tsExpected.rts r = Secret) let rec publicRegisterValuesAreAsExpected_reg_file (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : bool = if k = 0 then true else registerAsExpected (Reg rf (k - 1)) tsAnalysis tsExpected && publicRegisterValuesAreAsExpected_reg_file tsAnalysis tsExpected rf (k - 1) let rec publicRegisterValuesAreAsExpected_regs (tsAnalysis:analysis_taints) (tsExpected:analysis_taints) (k:nat{k <= n_reg_files}) : bool = if k = 0 then true else publicRegisterValuesAreAsExpected_reg_file tsAnalysis tsExpected (k - 1) (n_regs (k - 1)) && publicRegisterValuesAreAsExpected_regs tsAnalysis tsExpected (k - 1)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Leakage_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.Lib.MapTree.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Leakage_Helpers.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.MapTree", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Leakage_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": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tsAnalysis: Vale.X64.Leakage_Helpers.analysis_taints -> tsExpected: Vale.X64.Leakage_Helpers.analysis_taints -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Leakage_Helpers.analysis_taints", "Vale.X64.Leakage_Helpers.publicRegisterValuesAreAsExpected_regs", "Vale.X64.Machine_s.n_reg_files", "Prims.bool" ]
[]
false
false
false
true
false
let publicRegisterValuesAreAsExpected (tsAnalysis tsExpected: analysis_taints) : bool =
publicRegisterValuesAreAsExpected_regs tsAnalysis tsExpected n_reg_files
false
MiniParseExample2.fst
MiniParseExample2.somme_p
val somme_p : parser_spec somme
val somme_p : parser_spec somme
let somme_p = parse_sum (parse_bounded_u16 4) imp0 imp1
{ "file_name": "examples/miniparse/MiniParseExample2.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 8, "end_line": 100, "start_col": 0, "start_line": 96 }
(* 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 MiniParseExample2 open MiniParse.Spec.TSum module T = FStar.Tactics.V2 module U8 = FStar.UInt8 noeq type somme = | U of FStar.UInt8.t | V | W | X #set-options "--z3rlimit 16" let imp0 (x: somme) : Tot (bounded_u16 4) = match x with | U _ -> 0us <: bounded_u16 4 | V -> 1us <: bounded_u16 4 | W -> 2us <: bounded_u16 4 | _ -> 3us <: bounded_u16 4 #set-options "--print_universes --print_implicits" let c3 : sum_case #somme #(bounded_u16 4) imp0 3us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> X <: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) -> ()) () #set-options "--z3rlimit 64" let c2 : sum_case #somme #(bounded_u16 4) imp0 2us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> W <: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) -> ()) () let c1 : sum_case #somme #(bounded_u16 4) imp0 1us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> V <: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) -> ()) () let c0 : sum_case #somme #(bounded_u16 4) imp0 0us = Case #(bounded_u16 4) #somme U8.t parse_u8 serialize_u8 (fun (x: U8.t) -> U x <: refine_with_tag #(bounded_u16 4) #somme imp0 (0us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 0us) -> ( match x with | U x -> x )) () #reset-options let imp1 : (x: bounded_u16 4) -> Tot (sum_case #somme #(bounded_u16 4) imp0 x) = (bounded_u16_match_t_intro 4 imp0 ( bounded_u16_match_t_aux_cons 4 imp0 3 3us ( c3 ) ( bounded_u16_match_t_aux_cons 4 imp0 2 2us ( c2 ) ( bounded_u16_match_t_aux_cons 4 imp0 1 1us ( c1 ) ( bounded_u16_match_t_aux_cons_nil 4 imp0 ( c0 )))))) noextract val somme_p : parser_spec somme
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.TSum.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParseExample2.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "MiniParse.Spec.TSum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
MiniParse.Spec.Base.parser_spec MiniParseExample2.somme
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.TSum.parse_sum", "MiniParse.Spec.Int.bounded_u16", "MiniParse.Spec.Int.parse_bounded_u16", "MiniParseExample2.somme", "MiniParseExample2.imp0", "MiniParseExample2.imp1" ]
[]
false
false
false
true
false
let somme_p =
parse_sum (parse_bounded_u16 4) imp0 imp1
false
FStar.Buffer.Quantifiers.fst
FStar.Buffer.Quantifiers.lemma_create_quantifiers
val lemma_create_quantifiers: #a:Type -> h:mem -> b:buffer a -> init:a -> len:FStar.UInt32.t -> Lemma (requires (live h b /\ as_seq h b == Seq.create (v len) init)) (ensures (live h b /\ length b = v len /\ (forall (i:nat). {:pattern (get h b i)} i < length b ==> get h b i == init))) [SMTPat (as_seq h b); SMTPat (Seq.create (v len) init)]
val lemma_create_quantifiers: #a:Type -> h:mem -> b:buffer a -> init:a -> len:FStar.UInt32.t -> Lemma (requires (live h b /\ as_seq h b == Seq.create (v len) init)) (ensures (live h b /\ length b = v len /\ (forall (i:nat). {:pattern (get h b i)} i < length b ==> get h b i == init))) [SMTPat (as_seq h b); SMTPat (Seq.create (v len) init)]
let lemma_create_quantifiers #a h b init len = assert (Seq.length (as_seq h b) = v len); let lemma_post (i:nat) = i < length b ==> get h b i == init in let qi : i:nat -> Lemma (lemma_post i) = fun i -> assert (i < length b ==> get h b i == Seq.index (as_seq h b) i) in Classical.forall_intro #_ #lemma_post qi
{ "file_name": "ulib/legacy/FStar.Buffer.Quantifiers.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 59, "start_col": 0, "start_line": 54 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer.Quantifiers open FStar.Seq open FStar.UInt32 open FStar.HyperStack open FStar.Ghost open FStar.Buffer open FStar.Classical #set-options "--initial_fuel 0 --max_fuel 0" val lemma_sub_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t -> len:FStar.UInt32.t{v len <= length b /\ v i + v len <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b' /\ length b' = v len /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (v i + v len)); SMTPat (as_seq h b')] let lemma_sub_quantifiers #a h b b' i len = assert (Seq.length (Seq.slice (as_seq h b) (v i) (v i + v len)) = v len); let lemma_post (j:nat) = j < length b' ==> get h b' j == get h b (j + v i) in let qj : j:nat -> Lemma (lemma_post j) = fun j -> assert (j < v len ==> Seq.index (as_seq h b') j == Seq.index (as_seq h b) (j + v i)) in Classical.forall_intro #_ #lemma_post qj val lemma_offset_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t{v i <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b' /\ length b' = length b - v i /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (length b)); SMTPat (as_seq h b')] let lemma_offset_quantifiers #a h b b' i = lemma_sub_quantifiers #a h b b' i (uint_to_t (length b - v i)) val lemma_create_quantifiers: #a:Type -> h:mem -> b:buffer a -> init:a -> len:FStar.UInt32.t -> Lemma (requires (live h b /\ as_seq h b == Seq.create (v len) init)) (ensures (live h b /\ length b = v len /\ (forall (i:nat). {:pattern (get h b i)} i < length b ==> get h b i == init)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Buffer.fst.checked" ], "interface_file": false, "source_file": "FStar.Buffer.Quantifiers.fst" }
[ { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 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: FStar.Buffer.buffer a -> init: a -> len: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires FStar.Buffer.live h b /\ FStar.Buffer.as_seq h b == FStar.Seq.Base.create (FStar.UInt32.v len) init) (ensures FStar.Buffer.live h b /\ FStar.Buffer.length b = FStar.UInt32.v len /\ (forall (i: Prims.nat). {:pattern FStar.Buffer.get h b i} i < FStar.Buffer.length b ==> FStar.Buffer.get h b i == init)) [SMTPat (FStar.Buffer.as_seq h b); SMTPat (FStar.Seq.Base.create (FStar.UInt32.v len) init)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.buffer", "FStar.UInt32.t", "FStar.Classical.forall_intro", "Prims.nat", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims._assert", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "FStar.Buffer.length", "Prims.eq2", "FStar.Buffer.get", "FStar.Seq.Base.index", "FStar.Buffer.as_seq", "Prims.logical", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.op_GreaterThanOrEqual", "FStar.Seq.Base.length", "FStar.UInt32.v" ]
[]
false
false
true
false
false
let lemma_create_quantifiers #a h b init len =
assert (Seq.length (as_seq h b) = v len); let lemma_post (i: nat) = i < length b ==> get h b i == init in let qi: i: nat -> Lemma (lemma_post i) = fun i -> assert (i < length b ==> get h b i == Seq.index (as_seq h b) i) in Classical.forall_intro #_ #lemma_post qi
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.cur_formula
val cur_formula: Prims.unit -> Tac formula
val cur_formula: Prims.unit -> Tac formula
let cur_formula () : Tac formula = term_as_formula (cur_goal ())
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 26, "start_col": 0, "start_line": 26 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac FStar.Reflection.V1.Formula.formula
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Reflection.V1.Formula.term_as_formula", "FStar.Reflection.V1.Formula.formula", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.cur_goal", "FStar.Stubs.Reflection.Types.typ" ]
[]
false
true
false
false
false
let cur_formula () : Tac formula =
term_as_formula (cur_goal ())
false
FStar.Buffer.Quantifiers.fst
FStar.Buffer.Quantifiers.eq_lemma
val eq_lemma: #a:Type -> h:mem -> b:buffer a{live h b} -> h':mem -> b':buffer a{live h' b'} -> Lemma (requires (equal h b h' b')) (ensures (length b = length b' /\ (forall (i:nat). {:pattern (get h b i)} i < length b ==> get h b i == get h' b' i))) [SMTPat (equal h b h' b')]
val eq_lemma: #a:Type -> h:mem -> b:buffer a{live h b} -> h':mem -> b':buffer a{live h' b'} -> Lemma (requires (equal h b h' b')) (ensures (length b = length b' /\ (forall (i:nat). {:pattern (get h b i)} i < length b ==> get h b i == get h' b' i))) [SMTPat (equal h b h' b')]
let eq_lemma #a h b h' b' = assert(Seq.length (as_seq h b) = Seq.length (as_seq h' b')); let lemma_post (j:nat) = j < length b ==> get h b j == get h' b' j in let qj : j:nat -> Lemma (lemma_post j) = fun j -> assert(j < length b ==> Seq.index (as_seq h b) j == Seq.index (as_seq h' b') j) in Classical.forall_intro #_ #lemma_post qj
{ "file_name": "ulib/legacy/FStar.Buffer.Quantifiers.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 119, "start_col": 0, "start_line": 114 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer.Quantifiers open FStar.Seq open FStar.UInt32 open FStar.HyperStack open FStar.Ghost open FStar.Buffer open FStar.Classical #set-options "--initial_fuel 0 --max_fuel 0" val lemma_sub_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t -> len:FStar.UInt32.t{v len <= length b /\ v i + v len <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b' /\ length b' = v len /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (v i + v len)); SMTPat (as_seq h b')] let lemma_sub_quantifiers #a h b b' i len = assert (Seq.length (Seq.slice (as_seq h b) (v i) (v i + v len)) = v len); let lemma_post (j:nat) = j < length b' ==> get h b' j == get h b (j + v i) in let qj : j:nat -> Lemma (lemma_post j) = fun j -> assert (j < v len ==> Seq.index (as_seq h b') j == Seq.index (as_seq h b) (j + v i)) in Classical.forall_intro #_ #lemma_post qj val lemma_offset_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t{v i <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b' /\ length b' = length b - v i /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (length b)); SMTPat (as_seq h b')] let lemma_offset_quantifiers #a h b b' i = lemma_sub_quantifiers #a h b b' i (uint_to_t (length b - v i)) val lemma_create_quantifiers: #a:Type -> h:mem -> b:buffer a -> init:a -> len:FStar.UInt32.t -> Lemma (requires (live h b /\ as_seq h b == Seq.create (v len) init)) (ensures (live h b /\ length b = v len /\ (forall (i:nat). {:pattern (get h b i)} i < length b ==> get h b i == init))) [SMTPat (as_seq h b); SMTPat (Seq.create (v len) init)] let lemma_create_quantifiers #a h b init len = assert (Seq.length (as_seq h b) = v len); let lemma_post (i:nat) = i < length b ==> get h b i == init in let qi : i:nat -> Lemma (lemma_post i) = fun i -> assert (i < length b ==> get h b i == Seq.index (as_seq h b) i) in Classical.forall_intro #_ #lemma_post qi val lemma_index_quantifiers: #a:Type -> h:mem -> b:buffer a -> n:FStar.UInt32.t -> Lemma (requires (live h b /\ v n < length b)) (ensures (live h b /\ v n < length b /\ get h b (v n) == Seq.index (as_seq h b) (v n))) [SMTPat (Seq.index (as_seq h b) (v n))] let lemma_index_quantifiers #a h b n = () val lemma_upd_quantifiers: #a:Type -> h0:mem -> h1:mem -> b:buffer a -> n:FStar.UInt32.t -> z:a -> Lemma (requires (live h0 b /\ live h1 b /\ v n < length b /\ as_seq h1 b == Seq.upd (as_seq h0 b) (v n) z)) (ensures (live h0 b /\ live h1 b /\ v n < length b /\ (forall (i:nat). {:pattern (get h1 b i)} (i < length b /\ i <> v n) ==> get h1 b i == get h0 b i) /\ get h1 b (v n) == z)) [SMTPat (as_seq h1 b); SMTPat (Seq.upd (as_seq h0 b) (v n) z)] let lemma_upd_quantifiers #a h0 h1 b n z = assert(forall (i:nat). i < length b ==> get h1 b i == Seq.index (as_seq h1 b) i) #reset-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 8" val lemma_blit_quantifiers: #a:Type -> h0:mem -> h1:mem -> b:buffer a -> bi:UInt32.t{v bi <= length b} -> b':buffer a{disjoint b b'} -> bi':UInt32.t{v bi' <= length b'} -> len:UInt32.t{v bi+v len <= length b /\ v bi'+v len <= length b'} -> Lemma (requires (live h0 b /\ live h0 b' /\ live h1 b' /\ Seq.slice (as_seq h1 b') (v bi') (v bi'+v len) == Seq.slice (as_seq h0 b) (v bi) (v bi+v len) /\ Seq.slice (as_seq h1 b') 0 (v bi') == Seq.slice (as_seq h0 b') 0 (v bi') /\ Seq.slice (as_seq h1 b') (v bi'+v len) (length b') == Seq.slice (as_seq h0 b') (v bi'+v len) (length b') )) (ensures (live h0 b /\ live h0 b' /\ live h1 b' /\ (forall (i:nat). {:pattern (get h1 b' (v bi'+i))} i < v len ==> get h1 b' (v bi'+i) == get h0 b (v bi+i)) /\ (forall (i:nat). {:pattern (get h1 b' i)} ((i >= v bi' + v len /\ i < length b') \/ i < v bi') ==> get h1 b' i == get h0 b' i) )) let lemma_blit_quantifiers #a h0 h1 b bi b' bi' len = let lemma_post_1 (j:nat) = j < v len ==> get h1 b' (v bi'+j) == get h0 b (v bi+j) in let qj_1 : j:nat -> Lemma (lemma_post_1 j) = fun j -> assert (j < v len ==> Seq.index (Seq.slice (as_seq h1 b') (v bi') (v bi'+v len)) j == Seq.index (Seq.slice (as_seq h0 b) (v bi) (v bi+v len)) j) in let lemma_post_2 (j:nat) = ((j >= v bi' + v len /\ j < length b') \/ j < v bi') ==> get h1 b' j == get h0 b' j in let qj_2 : j:nat -> Lemma (lemma_post_2 j) = fun j -> assert (j < v bi' ==> Seq.index (Seq.slice (as_seq h1 b') 0 (v bi')) j == Seq.index (Seq.slice (as_seq h0 b') 0 (v bi')) j); assert ((j >= v bi' + v len /\ j < length b') ==> Seq.index (Seq.slice (as_seq h1 b') (v bi'+v len) (length b')) (j - (v bi'+v len)) == Seq.index (Seq.slice (as_seq h0 b') (v bi'+v len) (length b')) (j - (v bi'+v len))) in Classical.forall_intro #_ #lemma_post_1 qj_1; Classical.forall_intro #_ #lemma_post_2 qj_2 (* Equality predicate between buffers with quantifiers *) val eq_lemma: #a:Type -> h:mem -> b:buffer a{live h b} -> h':mem -> b':buffer a{live h' b'} -> Lemma (requires (equal h b h' b')) (ensures (length b = length b' /\ (forall (i:nat). {:pattern (get h b i)} i < length b ==> get h b i == get h' b' i)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Buffer.fst.checked" ], "interface_file": false, "source_file": "FStar.Buffer.Quantifiers.fst" }
[ { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 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": 8, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> b: FStar.Buffer.buffer a {FStar.Buffer.live h b} -> h': FStar.Monotonic.HyperStack.mem -> b': FStar.Buffer.buffer a {FStar.Buffer.live h' b'} -> FStar.Pervasives.Lemma (requires FStar.Buffer.equal h b h' b') (ensures FStar.Buffer.length b = FStar.Buffer.length b' /\ (forall (i: Prims.nat). {:pattern FStar.Buffer.get h b i} i < FStar.Buffer.length b ==> FStar.Buffer.get h b i == FStar.Buffer.get h' b' i)) [SMTPat (FStar.Buffer.equal h b h' b')]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.buffer", "FStar.Buffer.live", "FStar.Classical.forall_intro", "Prims.nat", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims._assert", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "FStar.Buffer.length", "Prims.eq2", "FStar.Seq.Base.index", "FStar.Buffer.as_seq", "Prims.logical", "FStar.Buffer.get", "Prims.op_Equality", "FStar.Seq.Base.length" ]
[]
false
false
true
false
false
let eq_lemma #a h b h' b' =
assert (Seq.length (as_seq h b) = Seq.length (as_seq h' b')); let lemma_post (j: nat) = j < length b ==> get h b j == get h' b' j in let qj: j: nat -> Lemma (lemma_post j) = fun j -> assert (j < length b ==> Seq.index (as_seq h b) j == Seq.index (as_seq h' b') j) in Classical.forall_intro #_ #lemma_post qj
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.l_revert
val l_revert: Prims.unit -> Tac unit
val l_revert: Prims.unit -> Tac unit
let l_revert () : Tac unit = revert (); apply (`revert_squash)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 36, "start_col": 0, "start_line": 34 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.apply", "FStar.Stubs.Tactics.V1.Builtins.revert" ]
[]
false
true
false
false
false
let l_revert () : Tac unit =
revert (); apply (`revert_squash)
false
FStar.Buffer.Quantifiers.fst
FStar.Buffer.Quantifiers.lemma_sub_quantifiers
val lemma_sub_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t -> len:FStar.UInt32.t{v len <= length b /\ v i + v len <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b' /\ length b' = v len /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (v i + v len)); SMTPat (as_seq h b')]
val lemma_sub_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t -> len:FStar.UInt32.t{v len <= length b /\ v i + v len <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b' /\ length b' = v len /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (v i + v len)); SMTPat (as_seq h b')]
let lemma_sub_quantifiers #a h b b' i len = assert (Seq.length (Seq.slice (as_seq h b) (v i) (v i + v len)) = v len); let lemma_post (j:nat) = j < length b' ==> get h b' j == get h b (j + v i) in let qj : j:nat -> Lemma (lemma_post j) = fun j -> assert (j < v len ==> Seq.index (as_seq h b') j == Seq.index (as_seq h b) (j + v i)) in Classical.forall_intro #_ #lemma_post qj
{ "file_name": "ulib/legacy/FStar.Buffer.Quantifiers.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 38, "start_col": 0, "start_line": 33 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer.Quantifiers open FStar.Seq open FStar.UInt32 open FStar.HyperStack open FStar.Ghost open FStar.Buffer open FStar.Classical #set-options "--initial_fuel 0 --max_fuel 0" val lemma_sub_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t -> len:FStar.UInt32.t{v len <= length b /\ v i + v len <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b' /\ length b' = v len /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) ))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Buffer.fst.checked" ], "interface_file": false, "source_file": "FStar.Buffer.Quantifiers.fst" }
[ { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 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: FStar.Buffer.buffer a -> b': FStar.Buffer.buffer a -> i: FStar.UInt32.t -> len: FStar.UInt32.t { FStar.UInt32.v len <= FStar.Buffer.length b /\ FStar.UInt32.v i + FStar.UInt32.v len <= FStar.Buffer.length b } -> FStar.Pervasives.Lemma (requires FStar.Buffer.live h b /\ FStar.Buffer.live h b' /\ FStar.Seq.Base.slice (FStar.Buffer.as_seq h b) (FStar.UInt32.v i) (FStar.UInt32.v i + FStar.UInt32.v len) == FStar.Buffer.as_seq h b') (ensures FStar.Buffer.live h b /\ FStar.Buffer.live h b' /\ FStar.Seq.Base.slice (FStar.Buffer.as_seq h b) (FStar.UInt32.v i) (FStar.UInt32.v i + FStar.UInt32.v len) == FStar.Buffer.as_seq h b' /\ FStar.Buffer.length b' = FStar.UInt32.v len /\ (forall (j: Prims.nat). {:pattern FStar.Buffer.get h b' j} j < FStar.Buffer.length b' ==> FStar.Buffer.get h b' j == FStar.Buffer.get h b (j + FStar.UInt32.v i))) [ SMTPat (FStar.Seq.Base.slice (FStar.Buffer.as_seq h b) (FStar.UInt32.v i) (FStar.UInt32.v i + FStar.UInt32.v len)); SMTPat (FStar.Buffer.as_seq h b') ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.buffer", "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "FStar.Buffer.length", "Prims.op_Addition", "FStar.Classical.forall_intro", "Prims.nat", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims._assert", "Prims.l_imp", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.index", "FStar.Buffer.as_seq", "Prims.logical", "FStar.Buffer.get", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.op_GreaterThanOrEqual", "FStar.Seq.Base.length", "FStar.Seq.Base.slice" ]
[]
false
false
true
false
false
let lemma_sub_quantifiers #a h b b' i len =
assert (Seq.length (Seq.slice (as_seq h b) (v i) (v i + v len)) = v len); let lemma_post (j: nat) = j < length b' ==> get h b' j == get h b (j + v i) in let qj: j: nat -> Lemma (lemma_post j) = fun j -> assert (j < v len ==> Seq.index (as_seq h b') j == Seq.index (as_seq h b) (j + v i)) in Classical.forall_intro #_ #lemma_post qj
false
FStar.Buffer.Quantifiers.fst
FStar.Buffer.Quantifiers.lemma_upd_quantifiers
val lemma_upd_quantifiers: #a:Type -> h0:mem -> h1:mem -> b:buffer a -> n:FStar.UInt32.t -> z:a -> Lemma (requires (live h0 b /\ live h1 b /\ v n < length b /\ as_seq h1 b == Seq.upd (as_seq h0 b) (v n) z)) (ensures (live h0 b /\ live h1 b /\ v n < length b /\ (forall (i:nat). {:pattern (get h1 b i)} (i < length b /\ i <> v n) ==> get h1 b i == get h0 b i) /\ get h1 b (v n) == z)) [SMTPat (as_seq h1 b); SMTPat (Seq.upd (as_seq h0 b) (v n) z)]
val lemma_upd_quantifiers: #a:Type -> h0:mem -> h1:mem -> b:buffer a -> n:FStar.UInt32.t -> z:a -> Lemma (requires (live h0 b /\ live h1 b /\ v n < length b /\ as_seq h1 b == Seq.upd (as_seq h0 b) (v n) z)) (ensures (live h0 b /\ live h1 b /\ v n < length b /\ (forall (i:nat). {:pattern (get h1 b i)} (i < length b /\ i <> v n) ==> get h1 b i == get h0 b i) /\ get h1 b (v n) == z)) [SMTPat (as_seq h1 b); SMTPat (Seq.upd (as_seq h0 b) (v n) z)]
let lemma_upd_quantifiers #a h0 h1 b n z = assert(forall (i:nat). i < length b ==> get h1 b i == Seq.index (as_seq h1 b) i)
{ "file_name": "ulib/legacy/FStar.Buffer.Quantifiers.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 82, "end_line": 75, "start_col": 0, "start_line": 74 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer.Quantifiers open FStar.Seq open FStar.UInt32 open FStar.HyperStack open FStar.Ghost open FStar.Buffer open FStar.Classical #set-options "--initial_fuel 0 --max_fuel 0" val lemma_sub_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t -> len:FStar.UInt32.t{v len <= length b /\ v i + v len <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b' /\ length b' = v len /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (v i + v len)); SMTPat (as_seq h b')] let lemma_sub_quantifiers #a h b b' i len = assert (Seq.length (Seq.slice (as_seq h b) (v i) (v i + v len)) = v len); let lemma_post (j:nat) = j < length b' ==> get h b' j == get h b (j + v i) in let qj : j:nat -> Lemma (lemma_post j) = fun j -> assert (j < v len ==> Seq.index (as_seq h b') j == Seq.index (as_seq h b) (j + v i)) in Classical.forall_intro #_ #lemma_post qj val lemma_offset_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t{v i <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b' /\ length b' = length b - v i /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (length b)); SMTPat (as_seq h b')] let lemma_offset_quantifiers #a h b b' i = lemma_sub_quantifiers #a h b b' i (uint_to_t (length b - v i)) val lemma_create_quantifiers: #a:Type -> h:mem -> b:buffer a -> init:a -> len:FStar.UInt32.t -> Lemma (requires (live h b /\ as_seq h b == Seq.create (v len) init)) (ensures (live h b /\ length b = v len /\ (forall (i:nat). {:pattern (get h b i)} i < length b ==> get h b i == init))) [SMTPat (as_seq h b); SMTPat (Seq.create (v len) init)] let lemma_create_quantifiers #a h b init len = assert (Seq.length (as_seq h b) = v len); let lemma_post (i:nat) = i < length b ==> get h b i == init in let qi : i:nat -> Lemma (lemma_post i) = fun i -> assert (i < length b ==> get h b i == Seq.index (as_seq h b) i) in Classical.forall_intro #_ #lemma_post qi val lemma_index_quantifiers: #a:Type -> h:mem -> b:buffer a -> n:FStar.UInt32.t -> Lemma (requires (live h b /\ v n < length b)) (ensures (live h b /\ v n < length b /\ get h b (v n) == Seq.index (as_seq h b) (v n))) [SMTPat (Seq.index (as_seq h b) (v n))] let lemma_index_quantifiers #a h b n = () val lemma_upd_quantifiers: #a:Type -> h0:mem -> h1:mem -> b:buffer a -> n:FStar.UInt32.t -> z:a -> Lemma (requires (live h0 b /\ live h1 b /\ v n < length b /\ as_seq h1 b == Seq.upd (as_seq h0 b) (v n) z)) (ensures (live h0 b /\ live h1 b /\ v n < length b /\ (forall (i:nat). {:pattern (get h1 b i)} (i < length b /\ i <> v n) ==> get h1 b i == get h0 b i) /\ get h1 b (v n) == z))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Buffer.fst.checked" ], "interface_file": false, "source_file": "FStar.Buffer.Quantifiers.fst" }
[ { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 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
h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> b: FStar.Buffer.buffer a -> n: FStar.UInt32.t -> z: a -> FStar.Pervasives.Lemma (requires FStar.Buffer.live h0 b /\ FStar.Buffer.live h1 b /\ FStar.UInt32.v n < FStar.Buffer.length b /\ FStar.Buffer.as_seq h1 b == FStar.Seq.Base.upd (FStar.Buffer.as_seq h0 b) (FStar.UInt32.v n) z) (ensures FStar.Buffer.live h0 b /\ FStar.Buffer.live h1 b /\ FStar.UInt32.v n < FStar.Buffer.length b /\ (forall (i: Prims.nat). {:pattern FStar.Buffer.get h1 b i} i < FStar.Buffer.length b /\ i <> FStar.UInt32.v n ==> FStar.Buffer.get h1 b i == FStar.Buffer.get h0 b i) /\ FStar.Buffer.get h1 b (FStar.UInt32.v n) == z) [ SMTPat (FStar.Buffer.as_seq h1 b); SMTPat (FStar.Seq.Base.upd (FStar.Buffer.as_seq h0 b) (FStar.UInt32.v n) z) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.buffer", "FStar.UInt32.t", "Prims._assert", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "FStar.Buffer.length", "Prims.eq2", "FStar.Buffer.get", "FStar.Seq.Base.index", "FStar.Buffer.as_seq", "Prims.unit" ]
[]
false
false
true
false
false
let lemma_upd_quantifiers #a h0 h1 b n z =
assert (forall (i: nat). i < length b ==> get h1 b i == Seq.index (as_seq h1 b) i)
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.fa_intro_lem
val fa_intro_lem (#a: Type) (#p: (a -> Type)) (f: (x: a -> squash (p x))) : Lemma (forall (x: a). p x)
val fa_intro_lem (#a: Type) (#p: (a -> Type)) (f: (x: a -> squash (p x))) : Lemma (forall (x: a). p x)
let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x)))
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 85, "end_line": 46, "start_col": 8, "start_line": 44 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (x: a -> Prims.squash (p x)) -> FStar.Pervasives.Lemma (ensures forall (x: a). p x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "FStar.Classical.lemma_forall_intro_gtot", "FStar.IndefiniteDescription.elim_squash", "Prims.unit", "Prims.l_True", "Prims.l_Forall", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let fa_intro_lem (#a: Type) (#p: (a -> Type)) (f: (x: a -> squash (p x))) : Lemma (forall (x: a). p x) =
FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x: a -> GTot (p x)))
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.forall_intro
val forall_intro: Prims.unit -> Tac binder
val forall_intro: Prims.unit -> Tac binder
let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro ()
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 51, "start_col": 0, "start_line": 49 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Stubs.Tactics.V1.Builtins.intro", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Derived.apply_lemma" ]
[]
false
true
false
false
false
let forall_intro () : Tac binder =
apply_lemma (`fa_intro_lem); intro ()
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.forall_intro_as
val forall_intro_as (s: string) : Tac binder
val forall_intro_as (s: string) : Tac binder
let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 56, "start_col": 0, "start_line": 54 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Prims.string -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.string", "FStar.Tactics.V1.Derived.intro_as", "FStar.Stubs.Reflection.Types.binder", "Prims.unit", "FStar.Tactics.V1.Derived.apply_lemma" ]
[]
false
true
false
false
false
let forall_intro_as (s: string) : Tac binder =
apply_lemma (`fa_intro_lem); intro_as s
false
Hacl.P256.PrecompTable.fst
Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lemma_w4
val precomp_g_pow2_192_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_192 16 precomp_g_pow2_192_table_lseq_w4 i)
val precomp_g_pow2_192_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_192 16 precomp_g_pow2_192_table_lseq_w4 i)
let precomp_g_pow2_192_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma ()
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 272, "start_col": 0, "start_line": 268 }
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15) let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4
{ "checked_file": "/", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 16}). Hacl.P256.PrecompTable.precomp_table_acc_inv Hacl.P256.PrecompTable.g_pow2_192 16 Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lseq_w4 i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.P256.PrecompTable.proj_g_pow2_192_lemma", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.P256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_192", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
true
false
true
false
false
let precomp_g_pow2_192_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma ()
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.forall_intros
val forall_intros: Prims.unit -> Tac binders
val forall_intros: Prims.unit -> Tac binders
let forall_intros () : Tac binders = repeat1 forall_intro
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 59, "start_col": 0, "start_line": 59 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binders
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.repeat1", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.forall_intro", "Prims.list", "FStar.Stubs.Reflection.Types.binders" ]
[]
false
true
false
false
false
let forall_intros () : Tac binders =
repeat1 forall_intro
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.implies_intro
val implies_intro: Prims.unit -> Tac binder
val implies_intro: Prims.unit -> Tac binder
let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro ()
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 79, "start_col": 0, "start_line": 77 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Stubs.Tactics.V1.Builtins.intro", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Derived.apply_lemma" ]
[]
false
true
false
false
false
let implies_intro () : Tac binder =
apply_lemma (`imp_intro_lem); intro ()
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.implies_intro_as
val implies_intro_as (s: string) : Tac binder
val implies_intro_as (s: string) : Tac binder
let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 83, "start_col": 0, "start_line": 81 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Prims.string -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.string", "FStar.Tactics.V1.Derived.intro_as", "FStar.Stubs.Reflection.Types.binder", "Prims.unit", "FStar.Tactics.V1.Derived.apply_lemma" ]
[]
false
true
false
false
false
let implies_intro_as (s: string) : Tac binder =
apply_lemma (`imp_intro_lem); intro_as s
false